连接远程数据库提示Access denied for user ‘root‘@‘xxx.xxx.xxx.xxx‘ (using password: YES)

一般来说,不管是服务器上的数据库还是本地的数据库,其他IP地址的访问都是没有权限的,需要的本机用户给予权限才能访问到。没有权限的访问就会报出错误:Access denied for user ‘root’@ ‘…’ (using password: YES)

登录mysql

mysql -uroot -p密码

执行一下mysql命令

use mysql
select host,user,authentication_string from user;
update user set host='%' where user ='root';
flush privileges;

重启mysql服务

service mysqld restart

亲测了虚拟机和服务器都可以,前提你的数据库账号密码要正确

猜你喜欢

转载自blog.csdn.net/weixin_44485316/article/details/130770015