Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'解决

安装上mysql后,报 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock',试了网上的方法都没有用,于是打开/etc/my.cnf查看。
看到这么一段:
 
# The MySQL server
 26 [mysqld]
 27 port            = 3306
 28 socket          = /tmp/mysql.sock
 29 skip-external-locking
 30 log-error=/alidata/log/mysql/error.log
 31 key_buffer_size = 16M
 32 max_allowed_packet = 1M
 33 table_open_cache = 64
 34 sort_buffer_size = 512K
 35 net_buffer_length = 8K
 36 read_buffer_size = 256K
 37 read_rnd_buffer_size = 512K
 38 myisam_sort_buffer_size = 8M
 
可知,使用的.sock文件,是/tmp/mysql.sock,而不是/var/run/mysqld/mysqld.sock,于是加个链接
     ln -s /tmp/mysql.sock /var/run/mysqld/mysqld.sock
解决
上一篇:C语言 复制字符串 malloc


下一篇:net-snmp添加自定义MIB