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

4
  • 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 Commented Jul 15, 2017 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 Commented Jul 15, 2017 at 23:37
  • same as you are trying, just use the -h option to specify the hostname - -h 127.0.0.1 Commented Jul 16, 2017 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 :/ Commented Jul 16, 2017 at 2:12

1 Answer 1

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.