登录
mysql -u root -p
//输入密码
设定允许访问 host
将host设置为通配符模式 %
Host
设置 %
便可远程访问了:
mysql> use mysql;
mysql> select 'host' from user where user='root';
+------+
| host |
+------+
| host |
| host |
| host |
+------+
3 rows in set (0.00 sec)
mysql> update user set host = '%' where user ='root';
ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
flush privileges;
是刷新MySQL的权限相关表,必须执行这一步操作。