缺省状态下,mysql的用户没有远程访问的权限。
改表法
mysql -u root -p
use mysql;
update user set host = '%' where user = 'root';
select host, user from user;
授权法
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION;//赋予任何主机访问数据的权限
FLUSH PRIVILEGES;//修改生效
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;