CentOS 8 settings to allow remote access to MySQL 8

1, the configuration /etc/my.cnf

vim /etc/my.cnf

Add the following:
bind-address=0.0.0.0

2, set user permissions

#登录MySQL
[root@sionas.com /]# mysql -u root -p
输入密码:


#### 允许远程访问(授权给所有ip)
mysql>CREATE USER 'root'@'%' IDENTIFIED BY 'password'; //此操作mysql 8.0中必须加
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION;  //任何远程主机都可以访问数据库 

mysql>FLUSH PRIVILEGES;


3. Set up a firewall

$ firewall-cmd --zone=public --add-port=3306/tcp --permanent
$ firewall-cmd --reload

4, restart mysql

$ service msyqld restart
Published 72 original articles · won praise 52 · views 310 000 +

Guess you like

Origin blog.csdn.net/qq_33833327/article/details/104776200