Mysql8.0 之常见错误解决(1130 Host is not allowed\1044 - Access denied for user)

xingyun86 2018-11-15 2305

1. 错误描述:ERROR 1130:Host 192.168.1.100 is not allowed to connect to this MySQL server.

开启外网访问,请确保root@%键值对存在。

如不存在,则执行一下语句:

CREATE USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';

并赋所有权限到root@%

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

1.1 MySQL5.7 - 8.0以上版本

a.开启root外网访问:(%  允许从任何ip登录, x.x.x.x 允许从指定ip访问)

> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';

> FLUSH PRIVILEGES;

b.开启root本地访问:(localhost对应127.0.0.1)

> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

> FLUSH PRIVILEGES;

1.2 MySQL 5.6及以下版本

a.开启root外网访问:(%  允许从任何ip登录, x.x.x.x 允许从指定ip访问)

> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

> FLUSH PRIVILEGES;

b.开启root本地访问:(localhost对应127.0.0.1)

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;

> FLUSH PRIVILEGES;

2. 错误描述:1044 - Access denied for user 'test'@'%' to database 'testdb'

开启外网访问,请确保root@%键值对存在。

如不存在,则执行一下语句:

CREATE USER 'test'@'%' IDENTIFIED WITH mysql_native_password BY '123456';

并赋所有权限到root@%

GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' WITH GRANT OPTION;

> FLUSH PRIVILEGES;





×
打赏作者
最新回复 (0)
查看全部
全部楼主
返回