1

I am trying to create a back up from a server by using XAMPP (via command prompt).

Unfortunately the error is: mysqldump: Got error: 2002: "Can't connect to MySQL server on 'x' (10060)" when trying to connect. I have looked a bit around on StackOverflow (mostly0, but most questions are regarding "access denied for user at (...)" or they're talking about MYSQL. I have tried finding the files that MYSQL should have (which they're discussing) and looked whether XAMPP had these as well (it did not).

My question is:

What could possibly be causing this error? I know the name, password and host are correct.

How have I tried backing up the database?

I opened Command Prompt with administrator rights.

I navigated to the correct directory where mysqldump is located at.

I then typed in: C:\xampp\mysql\bin>mysqldump -e -uNAME -pPWD -hHOST DATABASENAME > C:\winhostMySqlD.sql

It does create the .sql file, but CMD crashes with the error mentioned above.

1 Answer 1

2
mysqldump -e -uNAME -pPWD -hHOST DATABASENAME > C:\winhostMySqlD.sql

I hope you gave this command for representational purpose, if you execute this command as it is, you will get an error. Below mentioned sample command for your reference, and possible reason for the connection error:

To backup database mydbname:

mysqldump -u username -p password -h localhost mydbname > /path/filename.sql

To backup all databases:

mysqldump -u username -p password -h localhost --all-databases > /path/filename.sql

-u username - like admin/root
-p password - like 'Admin@123'
-h hostname - where mysql server is running - like localhost/192.168.x.x (IP address)

Check my post for learn more about backup and restoration.

Some of the reasons for connection errors, listed down for your troubleshooting:

  • MySQL Server is not running on the server.
  • MySQL socket file is missing / deleted / different location.
  • Security Enhanced Linux is protecting mysqld process (Linux).
  • MySQL server is bound to single address (bind_address).
  • Firewall blocking MySQL port.
  • Access restricted to the server hosts.

Check my post for detailed troubleshooting steps for above mentioned reason and other possible causes.

1
  • @Ratish, hello! Yes, the string I am representing is for representational purposes (or else everyone will see the db credentials). I will have a look into the articles and i'll come back to provide feedback on whether it solved the problem or not. Commented Mar 10, 2021 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.