下载地址
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19-1.el6.x86_64.rpm-bundle.tar
查询mariadb的版本号
rpm -qa|grep mariadb
如显示出:mariadb-libs-5.5.56-2.el7.x86_64,则说明系统使用的是该版本,可以对该版本进行卸载
卸载mariadb
sudo rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps
解压mysql
tar xvf mysql-5.7.19-1.el6.x86_64.rpm-bundle.tar
安装mysql
建议按顺序安装:common --> libs --> clients --> server
rpm -ivh mysql-community-libs-compat-5.7.19-1.el6.x86_64.rpm --nodeps rpm -ivh mysql-community-common-5.7.19-1.el6.x86_64.rpm --nodeps rpm -ivh mysql-community-libs-5.7.19-1.el6.x86_64.rpm --nodeps rpm -ivh mysql-community-client-5.7.19-1.el6.x86_64.rpm --nodeps rpm -ivh mysql-community-server-5.7.19-1.el6.x86_64.rpm --nodeps
# 查看mysql安装到哪里了
which mysqld
关闭防火墙
setenforce 0 systemctl stop firewalld.service systemctl disable firewalld.service
启动mysql
service mysqld start
查看root初始密码
more /var/log/mysqld.log |grep password
[Note] A temporary password is generated for root@localhost: OgoSH?xjg1hb
登录
mysql -uroot -p
修改密码规则以及修改密码
mysql>set global validate_password_length=4; mysql>set global validate_password_policy=0;
mysql>set password = password('root');
给任意IP授权
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES;