Linux上安装mysql5.7并开启远程连接

Linux(CentOS7)上安装mysql5.7并开启远程连接

1. 首先安装wegt

录入命令:yum -y install wget

2.下载并安装MySQL官方的Yum

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

3. 配置Mysql

1.启动mysql:systemctl start mysqld.service
2.找到mysql初始密码:grep “password” /var/log/mysqld.log
3.进入数据库:mysql -uroot -p
4.修改密码:ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘new password’;(新密码有字符要求限制,必须有大小写,特殊符号,数字。修改需重新设置)

4. 关闭CentOS7防火墙

1.关闭防火墙:systemctl stop firewalld.service
2.禁止开机启动:systemctl disable firewalld.service

5. 开启Mysql的远程连接

1.进入mysql后输入命令:GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘youpassword’ WITH GRANT OPTION;
在mysql控制台执行命令中的 ‘root’@’%’ 可以这样理解: root是用户名,%是主机名或IP地址,这里的%代表任意主机或IP地址,你也可替换成任意其它用户名或指定唯一的IP地址;'MyPassword’是给授权用户指定的登录数据库的密码

2.刷新缓存:flush privileges;

参考地址:
https://www.cnblogs.com/luohanguo/p/9045391.html
https://www.cnblogs.com/liluping860122/p/8881064.html

你可能感兴趣的:(Linux配置,mysql,linux,centos7)