patternsqlMinor
mysql works, mysqldump doesn't
Viewed 0 times
mysqlmysqldumpdoesnworks
Problem
I have mysql 5.5 on my ubuntu 12.04 server. This command:
works perfectly, but this gives me error:
In my.cnf file, the socket is set to:
so I have no idea where /var/run/mysqld/mysqld.sock is coming from. Thanks.
mysql -u root -pworks perfectly, but this gives me error:
mysqldump -u root -p mydb_name > a.sql
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when trying to connectIn my.cnf file, the socket is set to:
socket = /home/mysql/mysql.sockso I have no idea where /var/run/mysqld/mysqld.sock is coming from. Thanks.
Solution
When reading the configuration file, the
If your socket directive in the config file is in the
So where does
It turns out, Ubuntu compiles their MySQL components from source, and when they do that, they compile them to use
mysql command line client only reads configuration directives found in the [client] and [mysql] sections, while mysqldump only uses configuration directives found in the [client] and [mysqldump] sections.If your socket directive in the config file is in the
[mysql] section but not the [mysqldump] section then you should move it to the [client] section, and this should solve your problem.So where does
/var/run/mysqld/mysqld.sock come from? I remember very distinctly, once upon a time, beating my head against the wall repeatedly over that one.It turns out, Ubuntu compiles their MySQL components from source, and when they do that, they compile them to use
/var/run/mysqld/mysqld.sock unless the configuration file specifies otherwise or the socket is overridden on the command line... so if your socket directive isn't in [client] that would be one explanation of this behavior.Context
StackExchange Database Administrators Q#46296, answer score: 9
Revisions (0)
No revisions yet.