本地连接远程服务器数据库,却被服务器数据库拒绝
- 登录 mysql -u root -h localhost -p
- 打开 mysql 用户数据库: use mysql
- 将 host 的 localhost 设置为 % 表示任何 ip 都能连接mysql,当然您也可以将host指定为某个ip
update user set host='%' where user='root' and host='localhost';
- 刷新数据库
flush privileges;
update user set host='localhost' where user='root';