无法连接到远程 MySQL 服务器 (10061)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37916941/
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
Can't connect to Remote MySQL Server (10061)
提问by Hax0r
Localhost connection is enabled in MySQL.
本地主机连接在 MySQL 中启用。
But Remote(My laptop) access is disabled
但是远程(我的笔记本电脑)访问被禁用
Can't connect to MySQL server on "host" (10061)`.
My port always open 3306.
我的端口总是打开3306。
Here is my config file (/etc/mysql/my.cnf
) :
这是我的配置文件 ( /etc/mysql/my.cnf
):
#bind-address 0.0.0.0
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
And MySQL status is :
MySQL 状态是:
mysql start/running, process 15204
回答by Keugels
To allow remote access to MySQL, you have to comment out bind-address (you did) and skip-networking in the configuration file.
要允许远程访问 MySQL,您必须在配置文件中注释掉 bind-address(您做了)和 skip-networking。
Next, you have to make sure the user is allowed remote access. Check your user with this:
接下来,您必须确保允许用户远程访问。用这个检查你的用户:
SELECT User, Host FROM mysql.user;
If your user here has '127.0.0.1' or 'localhost' listed as host, you don't have remote access.
如果您的用户在此处将“127.0.0.1”或“localhost”列为主机,则您没有远程访问权限。
Change this with:
改变这一点:
UPDATE mysql.user SET HOST='%' WHERE User='__here_your_username';
Flush privileges:
刷权限:
FLUSH PRIVILEGES;
The '%' is a wildcard for 'all hosts'.
“%”是“所有主机”的通配符。
回答by Nesan Mano
To Allow remote access to MySQL installed on a Ubuntu, you will have to access the file at this location:
要允许远程访问安装在 Ubuntu 上的 MySQL,您必须访问以下位置的文件:
/etc/mysql/mysql.conf.d/mysqld.cnf
There, you comment out the following line: bind-address = 127.0.0.1
在那里,您注释掉以下行:bind-address = 127.0.0.1
basically to change: bind-address = 127.0.0.1 to: #bind-address = 127.0.0.1
基本上改变:绑定地址 = 127.0.0.1 到:#bind-address = 127.0.0.1
Now you either restart the computer or just the mySQL service using the follwing command: sudo /etc/init.d/mysql restart
现在,您可以使用以下命令重新启动计算机或仅重新启动 mySQL 服务: sudo /etc/init.d/mysql restart
回答by Arthuri-bibleArthur
In my case, installed LAMP stack on Oracle VM of Ubuntu 18.04
就我而言,在 Ubuntu 18.04 的 Oracle VM 上安装了 LAMP 堆栈
Here's my updateto mysql config file: /etc/mysql/mysql.conf.d/mysqld.cnf
这是我对 mysql 配置文件的更新:/etc/mysql/mysql.conf.d/mysqld.cnf
Before:
前:
bind-address = 127.0.0.1
After:
后:
# bind-address = 127.0.0.1
# comment out bind-address to test remote access
Ensure your user can access from remote host sudo mysql -u root -p Enter your password, then issue the command
确保您的用户可以从远程主机访问 sudo mysql -u root -p 输入您的密码,然后发出命令
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
+------------------+-------------------------------------------+-----------------------+--------------+ | user | authentication_string | plugin | host | +------------------+-------------------------------------------+-----------------------+--------------+
+-----------------+------------------------------ -------------+------------------------------+------------ --+ | 用户 | authentication_string | 插件 | 主机| +-----------------+------------------------------ -------------+------------------------------+------------ --+
| newuser | *9ACA980716AE084BCA56C59D19F3CEB7BB87B139 | mysql_native_password | 192.168.x.x | | newuser | *9ACA980716AE084BCA56C59D19F3CEB7BB87B139 | mysql_native_password | localhost |
| 新用户 | *9ACA980716AE084BCA56C59D19F3CEB7BB87B139 | mysql_native_password | 192.168.xx | | 新用户 | *9ACA980716AE084BCA56C59D19F3CEB7BB87B139 | mysql_native_password | 本地主机 |
This works for me, good luck.
这对我有用,祝你好运。
回答by Pratik Gaurav
The following worked for me.
以下对我有用。
SELECT User, Host FROM mysql.user;
UPDATE mysql.user SET HOST='%' WHERE User='root';
UPDATE mysql.user SET HOST='%' WHERE User='administrator';
FLUSH PRIVILEGES;
Then,
然后,
sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf
Change
改变
bind-address = 127.0.0.1 to: #bind-address = 127.0.0.1
save the file. reboot server/restart the MySQL
保存文件。重启服务器/重启 MySQL
回答by emily blunt
That bind-address = 127.0.0.1 config option means that your mysql server only accepts connections from the localhost, which is your actual CentOS machine. Make sure to set bind-address = 0.0.0.0
这个 bind-address = 127.0.0.1 配置选项意味着你的 mysql 服务器只接受来自本地主机的连接,本地主机是你实际的 CentOS 机器。确保设置 bind-address = 0.0.0.0
回答by jadki
For anyone else who is hosting the MySQL on a Raspberry Pi 3 the file you are looking for is in
对于在 Raspberry Pi 3 上托管 MySQL 的任何其他人,您要查找的文件位于
etc/mysql/mariadb.conf.d/50-server.cnf
You still need to follow the prior steps like listed above though by commenting out
您仍然需要按照上面列出的先前步骤进行注释
bind-address = 127.0.0.1
Hopefully this helps someone else from spending as much as time as I did for what appeared to be a missing line.
希望这可以帮助其他人花费与我一样多的时间来处理似乎丢失的线路。