linux部署mysql5.7

189 阅读1分钟

1.下载并安装MySQL官方的 Yum Repository

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm

2.禁用默认的mysql模块

yum module disable mysql

3.安装MySQL服务器

yum -y install mysql-community-server

4.如果报错GPG检查失败

vim /etc/yum.repos.d/mysql-community.repo
进入文件后把所有的gpgcheck=1改成gpgcheck=0,禁用检查

5.启动mysql

service mysqld start

6.查出mysql密码

grep "password" /var/log/mysqld.log

image.png

7.登录mysql

mysql -uroot -p
然后输入密码,输入的密码是不可见的,输入后回车登录

8.修改mysql密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
new password是设置的新密码

9.开启mysql的远程访问

grant all privileges on *.* to 'root'@'192.168.0.1' identified by 'password' with grant option;
如果报错当前密码策略不符,将密码校验等级设置为低,或者更换更复杂的密码
set global validate_password_policy=LOW;

10.刷新mysql权限,然后退出

flush privileges;
exit;