简体   繁体   中英

MySql Error ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

I'm following Vogella's tutorial on MySQL and I'm hitting a brick wall when I try to imitate the example. I've installed MySQL, and as he instructs I run it from the command line. When I do so, I get this error:

C:\Program Files (x86)\MySQL\MySQL Workbench CE 6.0.9>mysql -u root -p
Enter password: ******
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

C:\Program Files (x86)\MySQL\MySQL Workbench CE 6.0.9>

Does anyone know why?

The solution is very simple. The problem is the mysql service is not started. So we first need to start the mysql service before 'mysql -u user_name -p' command. To do that, navigate to 'bin' folder of mysql in command prompt. Eg:

C:\Program Files\MySQL\MySQL Server 5.7\bin>

In your case probably,

C:\Program Files (x86)\MySQL\MySQL Workbench CE 6.0.9\bin>

or

C:\Program Files (x86)\MySQL\bin>

or

If you have XAMPP installed, then to start mysql associated with it, navigate to

C:\xampp\mysql\bin>

then type the command mysqld -u root -p

It will output:

'2017-04-04 13:40:27 8536 [Note] mysqld (mysqld 10.1.21-MariaDB) starting as process 5640 ...'

This shows mysql is started.

Now type your command mysql -u root -p , it will work for sure.

try restarting the MYSQL app in the XAMPP control panel. It worked for me. Good luck!

Go to Start->Run and type services.msc. That's how you get to windows services window. Look for MySQL Server, Right Click, Start Service.

You could also get to Windows Services Window by Start -> Control Panel -> Administrative Tools -> Services

If there's no such service MySQL Server, then install MySQL Server from here https://dev.mysql.com/downloads/mysql/

Open the Xampp control panel and start the mysql module. For wamp, do the same. This is the simplest ever solution I've got !

mysql --protocol = TCP -P3306 -u用户-p

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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