无法连接到MySQL服务器错误113

时间:2021-10-17 01:58:27

Trying to make a simple connect to my servers MySQL database and I get

我试着简单地连接到我的服务器MySQL数据库

Warning: mysqli_connect(): (HY000/2003): Can't connect to MySQL server on '<host>' (113)

警告:mysqli_connect():( HY000 / 2003):无法连接到' '上的MySQL服务器(113)

netstat -tulpen has a :3306 record

netstat -tulpen有一个:3306记录

Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode       PID/Program name
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      999        801279      32067/mysqld

My bind-address in my.cnf is set to 0.0.0.0 and I still can't manage to connect to a database.

我在my.cnf中的绑定地址设置为0.0.0.0,我仍然无法连接到数据库。

My MySQL users

我的MySQL用户

+------------------+------------------------+
| User             | Host                   |
+------------------+------------------------+
| root             | 127.0.0.1              |
| root             | localhost              |
| root             | <ip>                   |
+------------------+------------------------+

I can connect from the inside of my server.

我可以从我的服务器内部连接。

What i'm missing?

我错过了什么?

Thank you in advance

先感谢您

2 个解决方案

#1


the 113 error shows "no route to host" error.you must configure your ip address on both machines.
of course,it must be routable.else, it wont work.

113错误显示“无路由到主机”错误。您必须在两台计算机上配置您的IP地址。当然,它必须是可路由的。但是,它不会工作。

#2


In your specific case, there are two options. The most likely is that your firewall is blocking that port still, so external cannot access. The alternative, and weirder one, is an identity issue. MySQL does not allow, by default, the admin user to login both internally AND externally. You will need to define a Host and User pair for this identity to be allowed somewhere other than "localhost" to login from.

在您的具体情况下,有两种选择。最可能的是您的防火墙仍在阻止该端口,因此外部无法访问。另一种选择,也是一种更奇怪的问题。默认情况下,MySQL不允许管理员用户在内部和外部登录。您需要定义一个主机和用户对,以允许此身份在“localhost”以外的地方登录。

First, login to mysql server, and then the mysql service.

    root# mysql -u root -p

Next, open the database named "mysql" and look at your user of interest. My example will be my "root" user.

接下来,打开名为“mysql”的数据库并查看您感兴趣的用户。我的例子将是我的“root”用户。

mysql> use mysql;
mysql> select * from user where User="root";
+-----------+------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+
| Host      | User | Password                                  | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections |
+-----------+------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+
| localhost | root | *A86DD7ED2F8269DFFDC595311DF5FF08872C12AB | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                |          |            |             |              |             0 |           0 |               0 |                    0 |
| kickseed  | root | *A86DD7ED2F8269DFFDC595311DF5FF08872C12AB | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                |          |            |             |              |             0 |           0 |               0 |                    0 |
| 127.0.0.1 | root | *A86DD7ED2F8269DFFDC595311DF5FF08872C12AB | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                |          |            |             |              |             0 |           0 |               0 |                    0 |
| 10.%.%.%  | root | *A86DD7ED2F8269DFFDC595311DF5FF08872C12AB | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                |          |            |             |              |             0 |           0 |               0 |                    0 |

As you can see, I have four separate entries for root: One for local, one for the loopback, one for server kickseed, and one for the development network. You will need to go through the create and grant steps as if it were a new user, and set your permissions accordingly.

正如您所看到的,我有四个单独的root条目:一个用于本地,一个用于环回,一个用于服务器kickseed,一个用于开发网络。您需要像创建新用户一样完成创建和授予步骤,并相应地设置权限。

#1


the 113 error shows "no route to host" error.you must configure your ip address on both machines.
of course,it must be routable.else, it wont work.

113错误显示“无路由到主机”错误。您必须在两台计算机上配置您的IP地址。当然,它必须是可路由的。但是,它不会工作。

#2


In your specific case, there are two options. The most likely is that your firewall is blocking that port still, so external cannot access. The alternative, and weirder one, is an identity issue. MySQL does not allow, by default, the admin user to login both internally AND externally. You will need to define a Host and User pair for this identity to be allowed somewhere other than "localhost" to login from.

在您的具体情况下,有两种选择。最可能的是您的防火墙仍在阻止该端口,因此外部无法访问。另一种选择,也是一种更奇怪的问题。默认情况下,MySQL不允许管理员用户在内部和外部登录。您需要定义一个主机和用户对,以允许此身份在“localhost”以外的地方登录。

First, login to mysql server, and then the mysql service.

    root# mysql -u root -p

Next, open the database named "mysql" and look at your user of interest. My example will be my "root" user.

接下来,打开名为“mysql”的数据库并查看您感兴趣的用户。我的例子将是我的“root”用户。

mysql> use mysql;
mysql> select * from user where User="root";
+-----------+------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+
| Host      | User | Password                                  | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections |
+-----------+------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+
| localhost | root | *A86DD7ED2F8269DFFDC595311DF5FF08872C12AB | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                |          |            |             |              |             0 |           0 |               0 |                    0 |
| kickseed  | root | *A86DD7ED2F8269DFFDC595311DF5FF08872C12AB | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                |          |            |             |              |             0 |           0 |               0 |                    0 |
| 127.0.0.1 | root | *A86DD7ED2F8269DFFDC595311DF5FF08872C12AB | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                |          |            |             |              |             0 |           0 |               0 |                    0 |
| 10.%.%.%  | root | *A86DD7ED2F8269DFFDC595311DF5FF08872C12AB | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y                     | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                |          |            |             |              |             0 |           0 |               0 |                    0 |

As you can see, I have four separate entries for root: One for local, one for the loopback, one for server kickseed, and one for the development network. You will need to go through the create and grant steps as if it were a new user, and set your permissions accordingly.

正如您所看到的,我有四个单独的root条目:一个用于本地,一个用于环回,一个用于服务器kickseed,一个用于开发网络。您需要像创建新用户一样完成创建和授予步骤,并相应地设置权限。