简体   繁体   English

MySQL拒绝远程连接

[英]MySQL Refusing Remote Connections

Using: MySQL/MariaDB Ver 14.14 Distrib 5.7.23 Ubuntu 16.04.5 LTS (GNU/Linux 2.6.32-042stab131.1 x86_64) 使用:MySQL / MariaDB版本14.14 Distrib 5.7.23 Ubuntu 16.04.5 LTS(GNU / Linux 2.6.32-042stab131.1 x86_64)

Everything works perfectly from the local machine (a remote dedicated server) such as PYPMyAdmin, SQLAlchemy, etc, but it will not accept any remote connections. 一切都可以在本地计算机(远程专用服务器)上正常运行,例如PYPMyAdmin,SQLAlchemy等,但是它不接受任何远程连接。 I can telnet to the MySQL port, it gives me a login prompt, and I have already set the remote user up with: 我可以远程登录到MySQL端口,它会给我一个登录提示,并且我已经使用以下命令设置了远程用户:

GRANT ALL PRIVILEGES ON . 授予所有特权 TO 'admin'@'%' IDENTIFIED BY 'p4$$w0rd' WITH GRANT OPTION; 通过授权选项以'p4 $$ w0rd'标识为'admin'@'%'; FLUSH PRIVILEGES; 冲洗特权;

And yet I still get the following error when I try to login remotely via Python/SQLAlchemy. 但是,当我尝试通过Python / SQLAlchemy远程登录时,仍然出现以下错误。 "Access denied for user 'admin'@'myrdns.myisp.net" “拒绝用户'admin'@'myrdns.myisp.net的访问”

Is there some additional security feature that I need to tweak that I am unaware of to enable remote access to one server from another? 是否需要调整一些我不知道的其他安全功能,以实现从另一台服务器到另一台服务器的远程访问?

You need to change/add grants for your desired username in order to access your database remotely, ie 您需要更改/添加所需用户名的权限,以便远程访问数据库,即

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

You'll need to issue the following command as well, before being able to connect. 在连接之前,您还需要发出以下命令。

FLUSH PRIVILEGES;

Since you (probably) did it already, you might wish to check your config file, in order to see if there's any bind address being set. 由于您(可能)已经这样做了,因此您可能希望检查配置文件,以查看是否设置了任何绑定地址。 In case of editing your config file, you'll need to issue server restart. 如果要编辑配置文件,则需要重启服务器。

Sometimes it's due to some firewall blocking rules as well, but you'll need to confirm and resolve it on your network/machine if that's the case. 有时,这也是由于某些防火墙阻止规则所致,但是如果是这种情况,则需要在网络/计算机上进行确认和解决。

Be warned, however, that it is advised that you set up SSL certificate if you allow remote access to your database. 但是请注意,如果允许远程访问数据库,建议您设置SSL证书。 Also be aware that you can issue remote login without logging in "directly", ie you can connect to your remote machine/server via SSH client , then connect to your mysql server via localhost/127.0.0.1 address. 还请注意,您可以发出远程登录而无需“直接”登录,即可以通过SSH客户端连接到远程计算机/服务器,然后通过localhost/127.0.0.1地址连接到mysql服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM