1.查看是否已安装并卸载
1)查看是否安装了MySQL数据库
rpm -qa | grep mysql
2)卸载
yum -y remove mysql-community-client-5.6.38-2.el7.x86_64
yum -y remove xxx 依次卸载直到没有
2.下载mysql的repo源并安装
cd /usr/local/src/ wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm rpm -ivh mysql57-community-release-el7-8.noarch.rpm yum -y install mysql-server
默认配置文件路径:
配置文件:/etc/my.cnf
3. 启动mysql服务
service mysqld restart
4 .重置密码并授权远程访问
4.1查看初始密码
# grep "password" /var/log/mysqld.log
找到root@localhost后面的一串就是初始密码
4.2 登陆到mysql
mysql -u root -p 密码
mysql对密码要求比较高,要求字母数字八位什么的
4.3设置使用简单密码
mysql>set global validate_password_policy=0;
mysql>set global validate_password_length=4;
4.4修改当前默认密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
4.5 授权root远程访问
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.100' IDENTIFIED BY '' WITH GRANT OPTION;
mysql> flush privileges;