$ mysql -u root -p -h 127.0.0.1输入密码:ERROR 2003 (HY000):无法连接到mysql服务器上的“127.0.0.1”(111)

时间:2021-10-28 20:41:14

I am just a beginner to the programming world. I spent more than 14 hours making dozens of changes suggested in various answers on this site, but unsuccessful. Can some one help me?

我只是编程世界的初学者。我花了14个多小时在这个网站上做了几十个不同的答案,但没有成功。有人能帮我吗?

I installed MySQL thru Cygwin.

我安装了MySQL thru Cygwin。

I do not see my.cnf file, but do have 4 files, my-small.cnf to my-huge.cnf files, in C:\cygwin64\usr\share\mysql.

我没有看到my.cnf文件,但是有4个文件,my-small.cnf到my-huge.cnf文件,在C:\cygwin64\usr\share\mysql。

$ which mysql
/usr/bin/mysql.

And, have my-small.cnf, but no binding-localhost entry

并且,有my-small.cnf,但没有绑定本地主机条目。

[client]
 #password       = your_password
 host            = 127.0.0.1
 port            = 3306
 socket          = /var/run/mysql/mysql.sock

If I enter first line, it prompts for password, but, the prompt does not accept any password nor move. If I enter anything, it will display error message.

如果我输入第一行,它会提示输入密码,但是提示符不会接受任何密码,也不会移动。如果我输入任何东西,它将显示错误消息。

$ mysql -u root -p -h 127.0.0.1
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)

OR, if I enter

或者,如果我输入

$ mysql -u root -p -h localhost
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql.sock' (2)

OR, for alias entry

或者,别名的条目

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

1 个解决方案

#1


0  

Please forgive me for using ELI5 Method for Explaining steps:

请原谅我用ELI5方法解释步骤:

It may be a good idea to UNINSTALL and RE-INSTALL:

卸载和重新安装可能是个好主意:

IF you have Completed the UN-INSTALLATION, then:

如果您已经完成了卸载,那么:

Make sure that your Cygwin Shell is CLOSED

确保你的Cygwin外壳是关闭的。

Using Cygwin setup-x86_64 (OR, setup-x86.exe, as appropriate for your system) start installation

使用Cygwin setup-x86_64(或setup-x86)。exe,适合您的系统)开始安装。

Search in the top-left window and find:

搜索左上方的窗口,然后找到:

mysql

mysqld

Proceed to Install and ACCEPT its dependencies (RECOMMENDED)

继续安装并接受它的依赖项(推荐)

Once the installation is FINISHED

安装完成后。

START Cygwin Shell

启动Cygwin壳

For Starting MySQL DATABASE setup:

启动MySQL数据库设置:

$ mysql_install_db

IF Firewall alert: (Choose appropriate)

如果防火墙警告:(选择适当)

For Running MySQL SERVER:

为运行MySQL服务器:

$ mysqld_safe &

IF Firewall alert: (Choose appropriate)

如果防火墙警告:(选择适当)

For Starting MySQL Installation:

为启动MySQL安装:

$ mysql_secure_installation

IF Firewall alert: (Choose appropriate)

如果防火墙警告:(选择适当)

Answering Questions:

回答问题:

root password: (Just enter, if you do not want)

根密码:(只要输入,如果你不需要)

remove anonymous users: y

删除匿名用户:y

disallow root login remotely: y (For the time being)

远程禁用root登录:y(暂时)

remove test database and access to it: y

删除测试数据库并访问它:y。

reload privilege tables now: y

重新加载特权表:y。

Now Start MySQL SERVER:

现在启动MySQL服务器:

$ mysqld_safe

Leave this window OPEN and you can MINIMIZE it if you want, and start another window using Alt+F2 OR using mouse by pointing to the top blue bar of the Cygwin Terminal (Window), then Right-click, and Click New

打开这个窗口,您可以最小化它,如果您想要的话,可以使用Alt+F2或者通过指向Cygwin终端(窗口)的顶部蓝色条来启动另一个窗口,然后右键单击,然后单击New。

For Starting MYSQL DATABASE, in NEW Window:

在新窗口中启动MYSQL数据库:

yourPC@PCuser ~/usr/sbin

yourPC@PCuser ~ / usr / sbin

(REPLACE yourPC & PCuser with the names you SEE on the Cygwin Terminal)

(用你在Cygwin终端上看到的名字替换你的pc和PCuser)

$ mysql -u root -h localhost

mysql> \h

(You can read all the help)

(你可以阅读所有的帮助)

mysql> \q

(For quitting mysql)

(用于戒烟mysql)

For Shutting Down MySQL SERVER

关闭MySQL服务器。

yourPC@PCuser ~/usr/sbin

yourPC@PCuser ~ / usr / sbin

(REPLACE yourPC & PCuser with the NAMES you see on the Cygwin Terminal)

(用你在Cygwin终端上看到的名字替换你的pc和PCuser)

$mysqladmin shutdown

IF the above does NOT shutdown, then:

如果以上不关机,则:

$ mysqladmin -u root shutdown

#1


0  

Please forgive me for using ELI5 Method for Explaining steps:

请原谅我用ELI5方法解释步骤:

It may be a good idea to UNINSTALL and RE-INSTALL:

卸载和重新安装可能是个好主意:

IF you have Completed the UN-INSTALLATION, then:

如果您已经完成了卸载,那么:

Make sure that your Cygwin Shell is CLOSED

确保你的Cygwin外壳是关闭的。

Using Cygwin setup-x86_64 (OR, setup-x86.exe, as appropriate for your system) start installation

使用Cygwin setup-x86_64(或setup-x86)。exe,适合您的系统)开始安装。

Search in the top-left window and find:

搜索左上方的窗口,然后找到:

mysql

mysqld

Proceed to Install and ACCEPT its dependencies (RECOMMENDED)

继续安装并接受它的依赖项(推荐)

Once the installation is FINISHED

安装完成后。

START Cygwin Shell

启动Cygwin壳

For Starting MySQL DATABASE setup:

启动MySQL数据库设置:

$ mysql_install_db

IF Firewall alert: (Choose appropriate)

如果防火墙警告:(选择适当)

For Running MySQL SERVER:

为运行MySQL服务器:

$ mysqld_safe &

IF Firewall alert: (Choose appropriate)

如果防火墙警告:(选择适当)

For Starting MySQL Installation:

为启动MySQL安装:

$ mysql_secure_installation

IF Firewall alert: (Choose appropriate)

如果防火墙警告:(选择适当)

Answering Questions:

回答问题:

root password: (Just enter, if you do not want)

根密码:(只要输入,如果你不需要)

remove anonymous users: y

删除匿名用户:y

disallow root login remotely: y (For the time being)

远程禁用root登录:y(暂时)

remove test database and access to it: y

删除测试数据库并访问它:y。

reload privilege tables now: y

重新加载特权表:y。

Now Start MySQL SERVER:

现在启动MySQL服务器:

$ mysqld_safe

Leave this window OPEN and you can MINIMIZE it if you want, and start another window using Alt+F2 OR using mouse by pointing to the top blue bar of the Cygwin Terminal (Window), then Right-click, and Click New

打开这个窗口,您可以最小化它,如果您想要的话,可以使用Alt+F2或者通过指向Cygwin终端(窗口)的顶部蓝色条来启动另一个窗口,然后右键单击,然后单击New。

For Starting MYSQL DATABASE, in NEW Window:

在新窗口中启动MYSQL数据库:

yourPC@PCuser ~/usr/sbin

yourPC@PCuser ~ / usr / sbin

(REPLACE yourPC & PCuser with the names you SEE on the Cygwin Terminal)

(用你在Cygwin终端上看到的名字替换你的pc和PCuser)

$ mysql -u root -h localhost

mysql> \h

(You can read all the help)

(你可以阅读所有的帮助)

mysql> \q

(For quitting mysql)

(用于戒烟mysql)

For Shutting Down MySQL SERVER

关闭MySQL服务器。

yourPC@PCuser ~/usr/sbin

yourPC@PCuser ~ / usr / sbin

(REPLACE yourPC & PCuser with the NAMES you see on the Cygwin Terminal)

(用你在Cygwin终端上看到的名字替换你的pc和PCuser)

$mysqladmin shutdown

IF the above does NOT shutdown, then:

如果以上不关机,则:

$ mysqladmin -u root shutdown