简体   繁体   English

mysqldump:无法连接到“ localhost”上的MySQL服务器

[英]mysqldump: Can't connect to MySQL server on 'localhost'

I have a strange mysqldump problem with MySQL 5.6.17. 我对MySQL 5.6.17有一个奇怪的mysqldump问题。 The server works fine, I can use mysql, mysqladmin, Workbench, but mysqldump is broken. 服务器工作正常,我可以使用mysql,mysqladmin,Workbench,但是mysqldump损坏了。

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 当我在工作台中连接到“§$)=事物时使用Export时,会出现相同的错误

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. 由于您的MySQL未在默认端口3306中运行,因此主要会出现此问题。

So first find which port MySQL server is running by using the following command in the MySQL command line client: 因此,首先在MySQL命令行客户端中使用以下命令查找正在运行哪个端口的MySQL服务器:

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: 然后将cmd目录设置为C:\\ Program Files \\ MySQL \\ MySQL Server 5.6 \\ bin>或安装MySQL的位置,然后执行以下命令进行导出:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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