Warning: count(): Parameter must be an array or an object that implements Countable in /www/wwwroot/ainto.org/usr/plugins/TpCache/driver/typecho_mysql.class.php on line 93
连接MySQL出现报错:1130- ‘host’ is not allowed to connect to this MySql server - Ainto

连接MySQL出现报错:1130- ‘host’ is not allowed to connect to this MySql server

发表在 教程 共有 0 条评论

1.改表法:

可能是你的帐号不允许从远程登陆,只能在localhost登录。这个时候只要在localhost的那台电脑,登入MySQL后,更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost”改称”%”

执行SQL

UPDATE USER SET HOST = '%' WHERE USER = 'root';
FLUSH RIVILEGES;

2.授权法:

如果你想用户名称:user 的用户使用密码:password 从任何主机连接到MySQL服务器的话

GRANT ALL PRIVILEGES ON*.* TO 'user'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;

如果你只想用户名称:user 的用户使用密码:password 从IP为192.168.1.5的主机连接到MySQL服务器的话

GRANT ALL PRIVILEGES ON*.* TO 'user'@'192.168.1.5' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;

如果你想用户名称:user 的用户使用密码:password 从IP为192.168.1.5的主机连接到MySQL服务器的“test”数据库的话

GRANT ALL PRIVILEGES ON test.* TO 'user'@'192.168.1.5' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;

3.取消授权

取消授权删除数据库“mysql”的“user”表中相关信息

评论已关闭