1. 程式人生 > >Centos下解除安裝、重灌、更新mysql

Centos下解除安裝、重灌、更新mysql

1、解除安裝mysql

(1)、檢視已裝的mysql版本

  1. [[email protected] ~]# yum list installed | grep mysql

  2. mysql.x86_64 5.1.73-8.el6_8 @base

  3. mysql-devel.x86_64 5.1.73-8.el6_8 @base

  4. mysql-libs.x86_64 5.1.73-8.el6_8 @base

  5. 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)、再次檢視,解除安裝完成

  1. [[email protected] ~]# rpm -qa|grep mysql

  2. [[email protected] ~]#

(4)、檢視系統自帶的mysql

  1. [[email protected] ~]# yum list | grep mysql

  2. apr-util-mysql.x86_64 1.3.9-3.el6_0.1 base

  3. bacula-director-mysql.x86_64 5.0.0-13.el6 base

  4. bacula-storage-mysql.x86_64 5.0.0-13.el6 base

  5. dovecot-mysql.x86_64 1:2.0.9-22.el6 base

  6. freeradius-mysql.x86_64 2.2.6-7.el6_9 updates

  7. libdbi-dbd-mysql.x86_64 0.8.3-5.1.el6 base

  8. mod_auth_mysql.x86_64 1:3.0.0-11.el6_0.1 base

  9. mysql.x86_64 5.1.73-8.el6_8 base

  10. mysql-bench.x86_64 5.1.73-8.el6_8 base

  11. mysql-connector-java.noarch 1:5.1.17-6.el6 base

  12. mysql-connector-odbc.x86_64 5.1.5r1144-7.el6 base

  13. mysql-devel.i686 5.1.73-8.el6_8 base

  14. mysql-devel.x86_64 5.1.73-8.el6_8 base

版本過低,選擇其他的源

2、安裝mysql

(1)獲取其它源

  1. [[email protected] ~]# cd /etc/yum.repos.d

  2. [[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)呵呵呵,報錯了

  1. [[email protected] yum.repos.d]# service mysqld start

  2. MySQL Daemon failed to start.

  3. 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)檢視版本

  1. [[email protected] lib]# mysql -V

  2. mysql Ver 14.14 Distrib 5.6.38, for Linux (x86_64) using EditLine wrapper

(8)修改密碼

  1. [[email protected] lib]# mysqladmin -u root password 123456

  2. Warning: Using a password on the command line interface can be insecure.

  3. [[email protected] lib]# mysql -u root -p

3、成功!