Everything negative-pressure,challenges-is all an opportunity for me to rise
16 August 2020
mysql> CREATE USER 'your_username'@'host_ip_addr' IDENTIFIED BY 'your_pwd';
host_ip_addr
是你要从其连接到MySQL 服务器的计算机的主机名或IP地址
%
用作host_ip_addr;mysql> GRANT ALL PRIVILEGES ON db_name.tab_name TO 'your_username'@'host_ip_addr' WITH GRANT OPTION;
db_name
是允许访问的数据库名称,*
表示任意数据库。
tab_name
是允许访问的表名称,*
表示任意表。
ALL PRIVILEGES
代表全局或者全数据库对象级别的所有权限。
mysql> FLUSH PRIVILEGES;
mysql> USE mysql;
mysql> SELECT host, user, plugin FROM user;
+------------+------------------+-----------------------+
| host | user | plugin |
+------------+------------------+-----------------------+
| % | ghost | caching_sha2_password |
| 172.17.0.% | root | caching_sha2_password |
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session | caching_sha2_password |
| localhost | mysql.sys | caching_sha2_password |
| localhost | root | caching_sha2_password |
+------------+------------------+-----------------------+
6 rows in set (0.00 sec)
1
2
3
sudo firewall-cmd --permanent --zone=public --add-service=mysql
OR
sudo firewall-cmd --permanent --zone=public --add-port=3306/tcp
1
sudo systemctl restart firewalld.service
编辑 /etc/my.cnf.d/community-mysql-server.cnf
, 导航到以bind-address
指令开头的行。将此指令设置为通配符IP地址*
,::
或0.0.0.0
:
1
bind-address = 0.0.0.0
保存重启MYSQL服务
1
sudo systemctl restart mysqld
— Lenox Xian