1,查看root远程登录访问
mysql> select host,user from user where user='root';
+-----------+------+
| host | user |
+-----------+------+
| % | root |
| 127.0.0.1 | root |
| localhost | root |
+-----------+------+
3 rows in set (0.00 sec)
2,设置root远程访问
mysql> grant all privileges on *.* to 'root'@'192.168.1.%' identified by 'root123456' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
3,刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
4,查看
mysql> select host,user from user where user='root';
+-------------+------+
| host | user |
+-------------+------+
| 127.0.0.1 | root |
| 192.168.1.% | root |
| localhost | root |
+-------------+------+
3 rows in set (0.00 sec)
本文详细介绍如何在MySQL中配置root用户以允许远程访问。通过执行特定的SQL语句,可以为root用户授予所有权限,并限制其从特定IP地址段进行访问。文章还提供了刷新权限缓存及验证设置的方法。

1万+

被折叠的 条评论
为什么被折叠?



