centos安装mysql5.6

75 阅读1分钟

1. 卸载服务器中的MySql

service mysql stop 1>/dev/null

service mysqld stop 1>/dev/null

rpm -qa | grep -i mysql | xargs -n1 rpm -e --nodeps 1>/dev/null

rpm -qa | grep -i mariadb | xargs -n1 rpm -e --nodeps 1>/dev/null

rm -rf /var/lib/mysql

rm -rf /usr/lib64/mysql

rm -rf /etc/my.cnf

rm -rf /usr/my.cnf

2. 下载安装MySql服务

rpm -ivh MySQL-server-5.6.50-1.el7.x86_64.rpm

安装完成后,输入cat /root/.mysql_secret后出现密码,牢记!!! cat /root/.mysql_secret

密码形式:52Nw4LmjbtKYIq0T

执行以下命令: mysql 查询状态命令 service mysql status

mysql 停止命令 service mysql stop

mysql 启动命令 service mysql start

3. 安装MySql客户端

rpm -ivh MySQL-client-5.6.50-1.el7.x86_64.rpm

4. 配置MySql

[root@master mysql-libs]# mysql -uroot -p52Nw4LmjbtKYIq0T 登录进去修改密码为123456

SET PASSWORD=PASSWORD('123456'); exit

[root@master mysql-libs]# mysql -uroot -p123456 use mysql; select User, Host, Password from user; update user set host='%' where host='localhost'; delete from user where Host='master'; delete from user where Host='127.0.0.1'; delete from user where Host='::1'; flush privileges; select User, Host, Password from user; quit;

配置文件位置/usr/my.cnf,配置utf8字符集

echo "character-set-server=utf8" >> /usr/my.cnf

重启mysql服务 service mysql restart

【注意:不要使用systemctl来管理mysql5.6】