Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 532 Bytes

200901.md

File metadata and controls

24 lines (17 loc) · 532 Bytes

服务器mysql允许远程连接

本地连接远程服务器数据库,却被服务器数据库拒绝

解决

  1. 登录 mysql -u root -h localhost -p
  2. 打开 mysql 用户数据库: use mysql
  3. 将 host 的 localhost 设置为 % 表示任何 ip 都能连接mysql,当然您也可以将host指定为某个ip
update user set host='%' where user='root' and host='localhost';
  1. 刷新数据库
flush privileges; 

重置为只能本地登录

 update user set host='localhost' where user='root';