I'm trying to retrieve a database from my Amazon RDS instance using mysqldump e.g.
mysqldump –h myDBname.cra3xhjrgj69.eu-west-1.rds.amazonaws.com -u root –p --port 3306 --single-transaction --databases DBname > ~/tt.sql
However I'm getting the error:
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) when trying to connect
I can connect to the database using the client however:
mysql --host=myDBname.cra3xhjrgj69.eu-west-1.rds.amazonaws.com -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 85250
Server version: 5.1.69-log MySQL Community Server (GPL)
I checked the root privileges as well:
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD '*abcabcabc' WITH GRANT OPTION
These looked OK.
Reading up on this issue I thought it may have been a version mismatch between my EC2 mysqldump and the RDS MySQL server version from this article:
Mysqldump 5.6 version needed on EC2 with MySQL 5.6
So I tried updating the client to version 5.6 however I still got the same error. I've tried various different versions now and have currently reverted to:
mysqldump -V
mysqldump Ver 10.13 Distrib 5.1.72, for unknown-linux-gnu (x86_64)
But I still get the same error. I've also tried connecting from another machine however the issue persists.
I'd appreciate it if anyone had any suggestions on what to try next. Seems like a workaround, if there was one wouldn't be too bad either right now.
Many thanks
-h
with mysqldump but--host=
with mysql. Does switching the way you supplied the option change the behavior? Also, check your my.cnf file for anything in the[mysqldump]
section. – Michael - sqlbotmysql
works andmysqldump
doesn't, although if you aren't using official Oracle binaries from the same version for both, all bets for sanity are off, because some 3rd party builds have strange "helpful" things compiled-in and active by default (like looking in strange places for config files and sockets). What if you add--protocol=TCP
to yourmysqldump
invocation? Or, what if you get the IP address by pinging your RDS instance's name and use--host=ip.add.re.ss
? Anything strange/interesting in the[client]
or[mysql]
sections of your my.cnf? – Michael - sqlbot