MySQL首次安装无法连接

问题

今天刚安装的MySQL数据库,远程无法连接,报错如下

null, message from server: "Host 'xxx.192.223.177' is not allowed to connect to this MySQL server"

解决

  • mysql -uroot -p 输入密码
  • show databases;
  • use mysql;
  • select user, host form user;//可以看到user为root,host为localhost的话,说明mysql只允许本机连接,那么外网,本地软件客户端就无法连接了。
  • update user set host = '%' where user='root';
  • flush privileges;//刷新权限
posted @ 2021-11-11 00:00  往事随雨  阅读(108)  评论(0)    收藏  举报