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中設置的值。