Centos下解除安裝、重灌、更新mysql
1、解除安裝mysql
(1)、檢視已裝的mysql版本
-
[[email protected] ~]# yum list installed | grep mysql
-
mysql.x86_64 5.1.73-8.el6_8 @base
-
mysql-devel.x86_64 5.1.73-8.el6_8 @base
-
mysql-libs.x86_64 5.1.73-8.el6_8 @base
-
mysql-server.x86_64 5.1.73-8.el6_8 @base
(2)、依次解除安裝,有依賴關係
[[email protected] ~]# yum -y remove mysql-5.1.73-8.el6_8.x86_64
[[email protected] ~]# yum -y remove mysql-libs.x86_64
(3)、再次檢視,解除安裝完成
-
[[email protected] ~]# rpm -qa|grep mysql
-
[[email protected] ~]#
(4)、檢視系統自帶的mysql
-
[[email protected] ~]# yum list | grep mysql
-
apr-util-mysql.x86_64 1.3.9-3.el6_0.1 base
-
bacula-director-mysql.x86_64 5.0.0-13.el6 base
-
bacula-storage-mysql.x86_64 5.0.0-13.el6 base
-
dovecot-mysql.x86_64 1:2.0.9-22.el6 base
-
freeradius-mysql.x86_64 2.2.6-7.el6_9 updates
-
libdbi-dbd-mysql.x86_64 0.8.3-5.1.el6 base
-
mod_auth_mysql.x86_64 1:3.0.0-11.el6_0.1 base
-
mysql.x86_64 5.1.73-8.el6_8 base
-
mysql-bench.x86_64 5.1.73-8.el6_8 base
-
mysql-connector-java.noarch 1:5.1.17-6.el6 base
-
mysql-connector-odbc.x86_64 5.1.5r1144-7.el6 base
-
mysql-devel.i686 5.1.73-8.el6_8 base
-
mysql-devel.x86_64 5.1.73-8.el6_8 base
版本過低,選擇其他的源
2、安裝mysql
(1)獲取其它源
-
[[email protected] ~]# cd /etc/yum.repos.d
-
[[email protected] yum.repos.d]# wget http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
(2)安裝
[[email protected] yum.repos.d]# yum install mysql-community-release-el6-5.noarch.rpm
[[email protected] yum.repos.d]# yum install mysql mysql-server
(3)啟動
[[email protected] yum.repos.d]# service mysqld start
(4)呵呵呵,報錯了
-
[[email protected] yum.repos.d]# service mysqld start
-
MySQL Daemon failed to start.
-
Starting mysqld: [FAILED]
(5)原因:我上個刪除的mysql沒有刪除歷史資料庫檔案
解決方法:刪除資料庫檔案
[[email protected] yum.repos.d]# cd /var/lib
[[email protected] lib]# rm -rf mysql
[[email protected] lib]# mkdir mysql
(6)再次啟動
[[email protected] lib]# service mysqld start
(7)檢視版本
-
[[email protected] lib]# mysql -V
-
mysql Ver 14.14 Distrib 5.6.38, for Linux (x86_64) using EditLine wrapper
(8)修改密碼
-
[[email protected] lib]# mysqladmin -u root password 123456
-
Warning: Using a password on the command line interface can be insecure.
-
[[email protected] lib]# mysql -u root -p
3、成功!