mysqldump: Got error:2002 can’t connect to local MySQL server through socket wher trying to connect html
1、查看mysql服务使用的socket路径mysql
[root@lyq314~]#netstat -nl |grep mysql sql
unix 2 [ ACC ] STREAM LISTENING 9287 /tmp/mysql.socksocket
2、修改.my.cnf 文件,问题解决。ide
3、出现2002问题,请参考下面。spa
mysql配置文件读取顺序.net
File Nameunix |
Purposeserver |
/etc/my.cnfhtm |
Global options |
/etc/mysql/my.cnf |
Global options |
SYSCONFDIR/my.cnf |
Global options |
$MYSQL_HOME/my.cnf |
Server-specific options |
defaults-extra-file |
The file specified with --defaults-extra-file=path, if any |
~/.my.cnf |
User-specific options |
读取顺序为:
/etc/my.cnf
basedir/my.cnf
datadir/my.cnf
--defaults-extra-file #在读取全局配置文件以后,读取用户配置文件(~/.my.cnf)以前,读取extra指定的参数文件
~/.my.cnf #家目录下面的隐藏文件,.my.cnf 。
假设4个配置文件都存在,同时使用--defaults-extra-file指定了参数文件,若是这时有一个"参数变量"在5个配置文件中都出现了,最终会使用~/.my.cnf中设置的值。