进行本地连接时,不允许主机连接到此 mysql 服务器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13731514/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 15:41:21  来源:igfitidea点击:

Host is not allowed to connect to this mysql server when making a local connection

mysqldatabaseputty

提问by kul_mi

When I try to connect with putty I get 'host is not allowed to connect to this mysql server'. Why is that happening? Host and client are on my machine.

当我尝试使用腻子连接时,我得到“不允许主机连接到此 mysql 服务器”。为什么会这样?主机和客户端在我的机器上。

When I connect with the command line it connects.

当我与命令行连接时,它会连接。

回答by Robert H

You need to change how your configuration is set up.

您需要更改配置的设置方式。

Comment out the skip-networking section within your MySQL config: # skip-networking, if you have skip-networkingit will discard any TCP/IP connection which is likely why your failing.

注释掉 MySQL 配置中的 skip-networking 部分:# skip-networking如果你有skip-networking它会丢弃任何 TCP/IP 连接,这可能是你失败的原因。

Once you have enabled your TCP/IP connections you will need to grant permission to your user to connect from other machines:

启用 TCP/IP 连接后,您需要授予用户从其他计算机连接的权限:

GRANT ALL PRIVILEGES ON *.* TO <username>@'%' IDENTIFIED BY '<password>';

GRANT ALL PRIVILEGES ON *.* TO <username>@'%' IDENTIFIED BY '<password>';

This will let username connect from any machine to your database with the appropriate password.

这将使用户名从任何机器使用适当的密码连接到您的数据库。