简体   繁体   English

MySQL数据库允许远程连接

[英]MySql database allow remote connections

I am using a synology 713+ nas server, and just started using MySQL with it. 我正在使用Synology 713+ nas服务器,并且刚刚开始使用MySQL。

I created a database, a table and a user with '%' as host, so it should be able to connect from anywhere. 我创建了一个数据库,一个表和一个以'%'作为主机的用户,因此它应该可以从任何地方进行连接。

Using the local ip to the nas-server, I am able to connect to the database without a problem. 使用本地IP到nas-server,我能够毫无问题地连接到数据库。 But when I try using the external ip, I get the following message instantly; 但是,当我尝试使用外部ip时,我会立即收到以下消息;

'Unable to connect to any of the specified MySQL hosts.' “无法连接到任何指定的MySQL主机。”

In the 'my.cnf' file, I have disabled 'skip-networking' and set 'bind-address' to 0.0.0.0. 在“ my.cnf”文件中,我禁用了“跳过网络连接”,并将“绑定地址”设置为0.0.0.0。

I am unable to see the 'bind-address' variable in phpMyAdmin, so I am unsure if it is actually using it. 我在phpMyAdmin中看不到'bind-address'变量,所以我不确定它是否在实际使用它。

If I try to connect while the database is offline, I times out after 30 seconds, but when it is online it refuses instantly, which tells me that it is able to find the server, but not allowed to connect. 如果在数据库脱机时尝试连接,我会在30秒后超时,但是在联机时它会立即拒绝,这告诉我它能够找到服务器,但不允许连接。

What in the world is going on, and what can I do? 世界上正在发生什么,我该怎么办?

Edit: 编辑:

All ports on the nas are open, and my router is forwarding port 3306 to the nas. nas上的所有端口均已打开,并且我的路由器将端口3306转发到nas。 Restarting mysql and the whole nas did not work. 重新启动mysql,整个nas无法正常工作。

I suspect the 'bind-address' variable is not being used... 我怀疑未使用'bind-address'变量...

I had a similar problem and I solved it this way: Try to create a new user from sql command of phpmyadmin like this: CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypassword'; 我有一个类似的问题,我是这样解决的:尝试通过phpmyadmin的sql命令创建一个新用户,如下所示:CREATE USER'myuser'@'%'IDENTIFIED BY'mypassword'; GRANT ALL ON * .* to myuser; 将所有* *授予myuser; and use this user for the connection. 并使用该用户进行连接。

MariaDB 10的默认端口是3307

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

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