1.输入命令查询系统中已安装的mysql

centos RPM方式安装MySQL5.6_第1张图片

2. . 逐个卸载mysql
 yum remove 系统显示已安装的mysql
 比如:yum remove MySQL-client-5.6.33-1.linux_glibc2.5.x86_64

3. 卸载完成后使用find命令来查找系统中存在的mysql文件夹
centos RPM方式安装MySQL5.6_第2张图片

4.使用rm -rf命令逐个删除文件夹路径即可
比如:rm -rf /etc/rc.d/init.d/mysql

5.安装MySQL
rpm -ivh MySQL-client-5.6.33-1.linux_glibc2.5.x86_64.rpm
rpm -ivh MySQL-server-5.6.33-1.linux_glibc2.5.x86_64.rpm

6. 修改配置文件
cp /usr/share/mysql/my-default.cnf /etc/my.cnf

7. 初始化MySQL及设置密码
/usr/bin/mysql_install_db
service mysql start
cat /root/.mysql_secret #查看root账号密码
mysql -u root –pqKTaFZnl
mysql> SET PASSWORD = PASSWORD('123456'); #设置密码为123456
mysql> exit

8. 设置远程访问
mysql> use mysql;
Database changed
mysql> grant all privileges on . to root@'%' identified by "password";
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

    mysql> select host,user,password from user;
    +--------------+------+-------------------------------------------+
    | host         | user | password                                  |
    +--------------+------+-------------------------------------------+
    | localhost    | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
    | 192.168.1.1 | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
    | %            | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
    +--------------+------+-------------------------------------------+
    3 rows in set (0.00 sec)

9. 设置开机自启动
加入到系统服务:
chkconfig --add mysql
自动启动:
chkconfig mysql on
查询列表:
chkconfig