可能是你的帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改”mysql” 数据库里的 “user” 表里的 “host”项,从”localhost”改称”%
# 登陆mysql mysql -uroot -p root # 选择数据库 use mysql; # 所有的地址都可以使用root用户来登陆 update user set host = '%' where user ='root'; #所有的地址都可以使用root用户,密码为12345678远程访问所有的数据库 grant all privileges on *.* to 'root'@'%' IDENTIFIED BY '12345678' with grant option; 所有的地址都可以使用root用户,远程访问所有的数据库 grant all privileges on *.* to 'root'@'%' with grant option; # 刷新数据库 flush privileges; # 退出数据库 exit; # 重启数据库 sudo service mysql restart;
文章评论