简体   繁体   中英

mysqldump: Can't connect to MySQL server on 'localhost'

I have a strange mysqldump problem with MySQL 5.6.17. The server works fine, I can use mysql, mysqladmin, Workbench, but mysqldump is broken.

mysqldump: Got error: 2003: Can't connect to MySQL server on 'localhost' (10013) when trying to connect

The same error appears when I use Export in Workbench while being connected to the "§$)= thing

Works:

mysql.exe -u username -ppassword dbname < test.sql

Works:

mysqladmin.exe -u username -ppassword variables

Error:

mysqldump.exe -u username -ppassword dbname > test.sql

I had this same issue. This problem mainly occurs since your MySQL is not running in the default port 3306.

So first find which port MySQL server is running by using the following command in the MySQL command line client:

SHOW GLOBAL VARIABLES LIKE 'PORT';

Then set the cmd directory to C:\\Program Files\\MySQL\\MySQL Server 5.6\\bin> or where ever your MySQL is installed and execute the following command for exporting:

mysqldump -u<username> -p -P<running port> <databasename> > <path>\mydb.sql

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