1.使数据库可以远程访问。
mysql>use mysql;
mysql>select host, user from user;
mysql>update user set host = '%' where user = 'root';
(此处我并没有直接使用update,而是新添加了一个root用户)
create user 'root' @ '%' identified by '*********';
2.授权
通过用户名和密码从任何主机连接到mysql服务器:
mysql>grant all privileges on *.* to 'root'@'%' identified by '*********' with grant option;
通过用户名和密码从特定主机(例如IP:122.122.122.122)连接到mysql服务器:
mysql>grant all privileges on *.* to 'root'@'122.122.122.122' identified by '****' with grant option;
3.生效
mysql> flush privileges;
4.测试
此处使用Navicat for MySQL测试;