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