错误2003 (HY000):无法连接到“127.0.0.1”的MySQL服务器(111)

时间:2022-09-19 22:31:16

I use the following command:

我使用以下命令:

mysql -u root -h 127.0.0.1 -p

and the error message is :

错误信息是:

ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)

Who can help me to fix it?

谁能帮我修好它?

12 个解决方案

#1


195  

If you are using ubuntu, you have to use the following steps to avoid this error(if there is no replication enabled):

如果您正在使用ubuntu,您必须使用以下步骤来避免此错误(如果没有启用复制):

  1. run the command vim /etc/mysql/my.cnf
  2. 运行命令vim /etc/mysql/my.cnf。
  3. comment bind-address = 127.0.0.1 using the # symbol
  4. 注释绑定地址= 127.0.0.1,使用#符号
  5. restart your mysql server once.
  6. 重新启动mysql服务器一次。

Update

更新

In Step 1, if you cannot find bind-address in the my.cnf file, look for it in /etc/mysql/mysql.conf.d/mysqld.cnf file.

在第一步,如果你不能找到文件,bind-address在my . cnf中所做寻找/etc/mysql/mysql.conf.d / mysqld.cnf文件。

Update in case of MySQL replication enabled

启用MySQL复制时进行更新

Try to connect MySQL server on IP for which MySQL server is bind in 'my.cnfinstead oflocalhost or 127.0.0.1`.

尝试将MySQL服务器与MySQL服务器绑定在“my.cnfinstead oflocalhost或127.0.0.1”上的IP连接起来。

#2


11  

Try localhost instead of 127.0.0.1 to connect or in your connection-config. Worked for me on a Debian Squeeze Server

尝试使用localhost而不是127.0.0.1来连接或连接配置。在Debian挤压服务器上为我工作

#3


4  

In my case (remote connnection) helped turning off firewall on server.

在我的例子中(远程连接)帮助关闭服务器上的防火墙。

service iptables stop

#4


4  

This problem may occur because your MySQL server is not installed and running. To do that start command prompt as admin and enter command:

这个问题可能会发生,因为您的MySQL服务器没有安装和运行。要执行启动命令提示符为admin并输入命令:

"C:\Program Files (x86)\MySQL\MySQL Server 5.1\bin\mysqld" --install

If you get "service successfully installed" message then you need to start the MySQL service. To do that: go to Services window (Task Manager -> Services -> Open Services) Search for MySQL and Start it from the top navigation bar. Then if try to open mysql.exe it will work.

如果您获得“服务成功安装”消息,则需要启动MySQL服务。要做到这一点,请到服务窗口(任务管理器->服务->开放服务)搜索MySQL并从顶部导航栏开始。如果尝试打开mysql。exe将工作。

#5


3  

This happens when you forget to start the database before connecting to it:

当您忘记在连接数据库之前启动数据库时,会发生以下情况:

mysql.server start

then

然后

mysql -u root -p -h 127.0.0.1

#6


3  

look at the my.cnf file, if there contain [client] section, and the port is other than real listen port (default 3306), you must connect the server with explicit parameter -P 3306, e.g.

查看my.cnf文件,如果包含[client]部分,且该端口不是真正的监听端口(默认为3306),则必须使用显式参数- p3306连接服务器,例如。

mysql -u root -h 127.0.0.1 -p -P 3306

mysql -u root -h 127.0.0.1 -p - p3306

#7


0  

You need to change the bind-address parameter to 127.0.0.1 in the mysql config file (my.ini or my.cnf) or use the one that is defined there.

您需要在mysql配置文件(my)中将绑定地址参数更改为127.0.0.1。ini或my.cnf)或使用这里定义的那个。

If that doesn't work you should check that the mysql service is actually running.

如果不成功,应该检查mysql服务是否正在运行。

#8


0  

Incase you are running on a non-default port, you may try using --port=<port num> provided --skip-networking is not enabled.

如果您正在一个非默认端口上运行,您可以尝试使用——port= 提供的端口——skip-networking不启用。

#9


0  

I just have this problem.... running in Win7 and wamp server ... after reading this

我只有这个问题....运行在Win7和wamp服务器…在阅读这篇文章之后

Found that Antivirus Firewall has caused the problem.

发现杀毒防火墙引起了这个问题。

#10


0  

I was also facing the same issue. The following helped me fix the problem go to control panel-> Administrative tools-->services inside this you will most certainly see the MySQL servce: right click and say start(force start).

我也面临着同样的问题。下面的代码帮助我修复了问题go to control panel—>管理工具—>服务,您肯定会看到MySQL servce:右键单击并输入start(force start)。

#11


-1  

i just restart my mysql server and the problem solved in windows net stop MySQL then net start MySQl ubuntu linux sudo service start mysql

我重新启动mysql服务器,windows net解决的问题停止mysql,然后net启动mysql ubuntu linux sudo服务启动mysql

#12


-1  

I changed the installation directory on re-install, and it worked.

我更改了重新安装的安装目录,并且成功了。

#1


195  

If you are using ubuntu, you have to use the following steps to avoid this error(if there is no replication enabled):

如果您正在使用ubuntu,您必须使用以下步骤来避免此错误(如果没有启用复制):

  1. run the command vim /etc/mysql/my.cnf
  2. 运行命令vim /etc/mysql/my.cnf。
  3. comment bind-address = 127.0.0.1 using the # symbol
  4. 注释绑定地址= 127.0.0.1,使用#符号
  5. restart your mysql server once.
  6. 重新启动mysql服务器一次。

Update

更新

In Step 1, if you cannot find bind-address in the my.cnf file, look for it in /etc/mysql/mysql.conf.d/mysqld.cnf file.

在第一步,如果你不能找到文件,bind-address在my . cnf中所做寻找/etc/mysql/mysql.conf.d / mysqld.cnf文件。

Update in case of MySQL replication enabled

启用MySQL复制时进行更新

Try to connect MySQL server on IP for which MySQL server is bind in 'my.cnfinstead oflocalhost or 127.0.0.1`.

尝试将MySQL服务器与MySQL服务器绑定在“my.cnfinstead oflocalhost或127.0.0.1”上的IP连接起来。

#2


11  

Try localhost instead of 127.0.0.1 to connect or in your connection-config. Worked for me on a Debian Squeeze Server

尝试使用localhost而不是127.0.0.1来连接或连接配置。在Debian挤压服务器上为我工作

#3


4  

In my case (remote connnection) helped turning off firewall on server.

在我的例子中(远程连接)帮助关闭服务器上的防火墙。

service iptables stop

#4


4  

This problem may occur because your MySQL server is not installed and running. To do that start command prompt as admin and enter command:

这个问题可能会发生,因为您的MySQL服务器没有安装和运行。要执行启动命令提示符为admin并输入命令:

"C:\Program Files (x86)\MySQL\MySQL Server 5.1\bin\mysqld" --install

If you get "service successfully installed" message then you need to start the MySQL service. To do that: go to Services window (Task Manager -> Services -> Open Services) Search for MySQL and Start it from the top navigation bar. Then if try to open mysql.exe it will work.

如果您获得“服务成功安装”消息,则需要启动MySQL服务。要做到这一点,请到服务窗口(任务管理器->服务->开放服务)搜索MySQL并从顶部导航栏开始。如果尝试打开mysql。exe将工作。

#5


3  

This happens when you forget to start the database before connecting to it:

当您忘记在连接数据库之前启动数据库时,会发生以下情况:

mysql.server start

then

然后

mysql -u root -p -h 127.0.0.1

#6


3  

look at the my.cnf file, if there contain [client] section, and the port is other than real listen port (default 3306), you must connect the server with explicit parameter -P 3306, e.g.

查看my.cnf文件,如果包含[client]部分,且该端口不是真正的监听端口(默认为3306),则必须使用显式参数- p3306连接服务器,例如。

mysql -u root -h 127.0.0.1 -p -P 3306

mysql -u root -h 127.0.0.1 -p - p3306

#7


0  

You need to change the bind-address parameter to 127.0.0.1 in the mysql config file (my.ini or my.cnf) or use the one that is defined there.

您需要在mysql配置文件(my)中将绑定地址参数更改为127.0.0.1。ini或my.cnf)或使用这里定义的那个。

If that doesn't work you should check that the mysql service is actually running.

如果不成功,应该检查mysql服务是否正在运行。

#8


0  

Incase you are running on a non-default port, you may try using --port=<port num> provided --skip-networking is not enabled.

如果您正在一个非默认端口上运行,您可以尝试使用——port= 提供的端口——skip-networking不启用。

#9


0  

I just have this problem.... running in Win7 and wamp server ... after reading this

我只有这个问题....运行在Win7和wamp服务器…在阅读这篇文章之后

Found that Antivirus Firewall has caused the problem.

发现杀毒防火墙引起了这个问题。

#10


0  

I was also facing the same issue. The following helped me fix the problem go to control panel-> Administrative tools-->services inside this you will most certainly see the MySQL servce: right click and say start(force start).

我也面临着同样的问题。下面的代码帮助我修复了问题go to control panel—>管理工具—>服务,您肯定会看到MySQL servce:右键单击并输入start(force start)。

#11


-1  

i just restart my mysql server and the problem solved in windows net stop MySQL then net start MySQl ubuntu linux sudo service start mysql

我重新启动mysql服务器,windows net解决的问题停止mysql,然后net启动mysql ubuntu linux sudo服务启动mysql

#12


-1  

I changed the installation directory on re-install, and it worked.

我更改了重新安装的安装目录,并且成功了。