CentOS 卸载MySQL 5.6 并安装MySQL 5.7

卸载5.6

https://my.oschina.net/xinall/blog/374053

yum方式安装的mysql

  1. yum remove mysql mysql-server mysql-libs compat-mysql51
  2. rm -rf /var/lib/mysql
  3. rm /etc/my.cnf
查看是否还有mysql软件:

rpm -qa|grep mysql

如果存在的话,继续删除即可。

rpm方式安装的mysql
  1. 查看系统中是否以rpm包安装的mysql:
    rpm -qa | grep -i mysql
    系统应该会返回:

MySQL-server-5.6.17-1.el6.i686
MySQL-client-5.6.17-1.el6.i686

  1. 卸载mysql
    rpm -e MySQL-server-5.6.17-1.el6.i686
    rpm -e MySQL-client-5.6.17-1.el6.i686

  2. 删除mysql服务

chkconfig --list | grep -i mysql
chkconfig --del mysql

  1. 删除分散mysql文件夹
    whereis mysql 或者 find / -name mysql

mysql: /usr/lib/mysql /usr/share/mysql

清空相关mysql的所有目录以及文件

rm -rf /usr/lib/mysql
rm -rf /usr/share/mysql
rm -rf /usr/my.cnf

通过以上几步,mysql应该已经完全卸载干净了

安装5.7

https://segmentfault.com/a/1190000003049498

  1. 检测系统是否自带安装mysql
    yum list installed | grep mysql

  2. 删除系统自带的mysql及其依赖命令:
    yum -y remove mysql-libs.x86_64

  3. 给CentOS添加rpm源,并且选择较新的源命令:

    wget dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
    yum localinstall mysql-community-release-el6-5.noarch.rpm
    yum repolist all | grep mysql
    yum-config-manager --disable mysql55-community
    yum-config-manager --disable mysql56-community
    yum-config-manager --enable mysql57-community-dmr
    yum repolist enabled | grep mysql

  4. 安装mysql 服务器命令:

yum install mysql-community-server

  1. 启动mysql命令:

service mysqld start

  1. 查看mysql是否自启动,并且设置开启自启动命令:

chkconfig --list | grep mysqld
chkconfig mysqld on

  1. mysql安全设置命令:
    mysql_secure_installation

备注

1. yum install mysql-community-server命令提示有冲突confilict导致安装中断

    1. `rpm -e 冲突的包名` 删除旧包
    2. `yum-complete-transaction` 继续安装过程
添加新评论