0

So I'm switching VPSs, and have already done a backup of all the data files and moved them over. However I still need to move all the old databases over. I've been searching the internet for the best way of doing so, but am undecided. I attempted to use the mysqldump command, then use scp to transfer the file, and import the database on the new server, however I was getting an error from doing that, and it would be more preferable if I could transfer all databases at once. If that isn't possible, then I would do them 1 at a time but I'll need to get this error fixed.

mysqldump: Got error: 2002: Can't connect to local MySQL server through socket ' /var/lib/mysql/mysql.sock' (2) when trying to connect

Thank you <3

  • Is your mysql server configured to listen to a socket (it isn't, that is the error...) or a tcp/ip port? When connecting and using "localhost" as the server hostname, it typically will try to use a socket (your error). Try specifying connection to 127.0.0.1 instead – ivanivan Jul 15 '17 at 13:03
  • What command would I want to use to dump all databases (-A, need to transfer everything), while still specifying the IP? :/ sorry – Jev4n5 Jul 15 '17 at 23:37
  • same as you are trying, just use the -h option to specify the hostname - -h 127.0.0.1 – ivanivan Jul 16 '17 at 2:06
  • mysqldump -u root -p -h 127.0.0.1 --opt db1 > db1.sql Enter password: mysqldump: Got error: 2003: Can't connect to MySQL server on '127.0.0.1' (111) when trying to connect :/ – Jev4n5 Jul 16 '17 at 2:12
0

A thought could be to set up replication with secondary node on the new Server. Upon reaching cutover time change the master node and pintpoint your new "master DB" as your primary DB. For the error you cold check configuration of the DB.

/etc/my.cnf
/etc/mysql/my.cnf
/var/lib/mysql/my.cnf

In the files may be confliction on where the sock may be. Remove/rename the /etc/mysql/my.cnf and impact should be lifted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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