MySQL使用-h连接报错Host ‘xxx‘ is not allowed to connect to this MySQL server

我这里使用mysql -h 192.168.0.108 -u root -p-h后边跟的是ip,结果发现报错如下:

ERROR 1130 (HY000): Host 'zhaoseaside' is not allowed to connect to this MySQL server

在这里插入图片描述

我才知道我没有开远程连接,然后使用mysql -u root -p本机登录,然后输入grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;,需要注意的是identified by 'root'中的root是密码。
MySQL使用-h连接报错Host ‘xxx‘ is not allowed to connect to this MySQL server_第1张图片

之后再使用mysql -h 192.168.0.108 -u root -p,就可以正常登录。
MySQL使用-h连接报错Host ‘xxx‘ is not allowed to connect to this MySQL server_第2张图片

你可能感兴趣的:(MySQL学习,mysql,数据库)