1、備份數(shù)據(jù)庫,升級MySQL通常不會丟失數(shù)據(jù),但保險起見,我們需要做這一步。輸入命令:
mysqldump -u xxx -h xxx -P 3306 -p --all-databases > databases.sql
停止MySQL服務,輸入命令:
service mysqld stop
卸載舊版MySQL,輸入命令:
yum remove mysql mysql-*
執(zhí)行過程中會詢問你是否移除,此時輸入“Y”
查看已安裝的軟件:rpm -qa|grep mysql
卸載mysql:yum remove mysql mysql-server mysql-libs compat-mysql51
移除命令執(zhí)行后,可再看看是否有殘余的mysql,輸入命令:
yum list installed | grep mysql
如果有,可輸入命令刪除:
yum remove mysql-libs
5、
下載安裝最新的rpm文件。
這步要看你需要什么文件,我安裝的是:mysql57-community-release-el6-7.noarch.rpm(如果提前得到了這個文件,第6步可以使用yum localinstallmysql57-community-release-el6-7.noarch.rpm從本地安裝)
rpm -Uvh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
安裝MySQL,輸入命令(過程中問詢是否yes,一路y下去):
yum install mysql-community-server
安裝完成后,輸入命令查看MySQL版本號:
mysql -V
啟動MySQL,輸入命令:
service mysqld start
service mysqld start
9、進入mysql后,第一件事件就是要你改默認密碼。mysql 5.7以后,系統(tǒng)自動生成隨機的密碼,我操作時,沒登錄上,切換mysql到安全模式啟動,自己去修改即可(安全模式修改密碼,見另一篇文章:MySQL忘記密碼,或:root密碼重置報錯:mysqladmin: connect to server at 'localhost' failed的解決方案)。
[root@c12 mysql57]# ./bin/mysql -u root -p
ERROR 1820 (HY000): You must reset your passWord using ALTER USER statement before executing this statement.
mysql> alter user root identified by 'root';ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
使用mysqladmin總算能改了[root@c12 mysql57]# ./bin/mysqladmin -u root -p passwordEnter password: New password: Confirm new password: Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
mysql> select version();+-----------+| version() |+-----------+| 5.7.8-rc |+-----------+1 row in set (0.00 sec)
10、設置mysql為開機啟動
chkconfig --list 顯示服務列表
如果看到mysqld的服務,并且3,4,5都是on的話則成功,如果是off,則鍵入
chkconfig --level 345 mysqld onreboot重啟電腦netstat -na | grep 3306,如果看到有監(jiān)聽說明服務啟動了。也可以用:service mysqld status看狀態(tài)
新聞熱點
疑難解答
圖片精選