1 将相關的mysql rpm包上傳到redhat上
2 我的電腦是redhat 6.*版本,是以這裡使用上面一個
3 解壓zip包
4 安裝以下幾個rpm
mysql-client-advanced-5.6.20-1.el6.x86_64.rpm
mysql-server-advanced-5.6.20-1.el6.x86_64.rpm
5
檢視已經安裝過的mysql
rpm –aq | grep mysql
結果:
mysql-libs-5.1.66-2.el6_3.x86_64
mod_auth_mysql-3.0.0-11.el6_0.1.x86_64
mysql-connector-java-5.1.17-6.el6.noarch
mysql-test-5.1.66-2.el6_3.x86_64
mysql-devel-5.1.66-2.el6_3.x86_64
libdbi-dbd-mysql-0.8.3-5.1.el6.x86_64
qt-mysql-4.6.2-25.el6.x86_64(這個不用解除安裝)
rsyslog-mysql-5.8.10-6.el6.x86_64
mysql-bench-5.1.66-2.el6_3.x86_64
mysql-connector-odbc-5.1.5r1144-7.el6.x86_64
dovecot-mysql-2.0.9-5.el6.x86_64
php-mysql-5.3.3-22.el6.x86_64
mysql-5.1.66-2.el6_3.x86_64
mysql-server-5.1.66-2.el6_3.x86_64
說明上面這些mysql相關的已經安裝了。
6
解除安裝上面安裝過的mysql
使用rpm –e mysql –nodeps –allmatches (不理會依賴關系,删除所有上一步查出來的相同的mysql)指令解除安裝上面不需要的mysql
例如:
rpm -e mysql-libs-5.1.66-2.el6_3.x86_64--nodeps –allmatches
按照相同的指令對安裝的其它mysql進行删除。
7
将老版本的幾個檔案手工删除
[root@localhost mysql]# rm -f /etc/my.cnf
[root@localhost mysql]# rm -rf/var/lib/mysql
[root@localhost mysql]# rm -rf/var/share/mysql
[root@localhost mysql]# rm -rf/usr/bin/mysql*
[root@localhost mysql]#
8
安裝mysql伺服器端
[root@localhost mysql]# rpm -ivhmysql-server-advanced-5.6.20-1.el6.x86_64.rpm
preparing...
###########################################[100%]
1:mysql-server-advanced ########################################### [100%]
2014-10-12 15:22:30 0 [warning] timestampwith implicit default value is deprecated. please use--explicit_defaults_for_timestamp server option (see documentation
for moredetails).
2014-10-12 15:22:30 6074 [note] innodb:using atomics to ref count buffer pool pages
2014-10-12 15:22:30 6074 [note] innodb:database physically writes the file full: wait...
2014-10-12 15:22:31 6074 [note] innodb:setting log file ./ib_logfile101 size to 48 mb
關于說明資訊:
a random password has been set for themysql root user !
you will find thatpassword in '/root/.mysql_secret'.
you must changethat password on your first connect,
no other statement but 'set password' willbe accepted.
see the manual for thesemantics of the 'password expired' flag.
also, the account for theanonymous user has been removed.
in addition, you can run:
/usr/bin/mysql_secure_installation
which will also give you the option ofremoving the test database.
this is strongly recommended for productionservers.
see the manual for more instructions.
please report any problems athttp://bugs.mysql.com/
the latest information about mysql isavailable on the web at
http://www.mysql.com
support mysql by buying support/licenses athttp://shop.mysql.com
new default config file was created as/usr/my.cnf and
will be used by default by the server whenyou start it.
you may edit this file to change serversettings
9
安裝mysql
的用戶端
[root@localhost mysql]# rpm -ivhmysql-client-advanced-5.6.20-1.el6.x86_64.rpm
preparing... ########################################### [100%]
1:mysql-client-advanced ########################################### [100%]
10
安裝mysql-devel-advanced-5.6.20-1.el6.x86_64.rpm
[root@localhost mysql]# rpm -ivhmysql-devel-advanced-5.6.20-1.el6.x86_64.rpm
1:mysql-devel-advanced ########################################### [100%]
11
修改mysql的密碼,第一次安裝的時候在,第一次安裝的時候的密碼檔案在/root/.mysql_secret中
修改密碼:
[root@localhost ~]# pwd
/root
12
檢視密碼:cat.mysql_secret
oracle收購mysql後,新版的mysql剛安裝完mysql後不能直接輸入mysql登入資料庫,而是設定了預設free
password密碼,預設密碼放在了/root/.mysql_secret檔案中,登陸後需要修改密碼.
13
修改密碼
a
啟動mysql
service mysql start
b
如果想關閉服務,指令是servicemysql stop
14
登入伺服器
mysql -u root -p
為使用者設定新密碼
set password=password('123456');
也可以使用腳本 /usr/bin/mysql_secure_installation進行互動式的修改mysql的root密碼
15.重新啟動一下redhat作業系統,然後再登陸(修改後再登陸發現登陸不了)