之前yum安装过mysql,今天把mysql5.5版本正式加到生产环境中,登陆phpmyadmin配置用户的时候报错:
2002 – 服务器没有响应 (or the local MySQL server’s socket is not correctly configured)
说socket没有正确配置。
/etc/mysql.cnf socket位置为/tmp/mysql.sock ,用phpinfo查看的socket路径为之前老版本数据库位置。
我这里解决方法是:
mv /var/lib/mysql /var/lib/mysql_bak && mkdir /var/lib/mysql && chmod 777 /var/lib/mysql
然后修改my.cnf为:
socket = /var/lib/mysql/mysql.sock
重启服务解决。
另一个方法是修改php.ini:
mysql.default_socket = /tmp/mysql.sock //网上有的朋友们说没效果,不知原因。我这里可以。
mysqli.default_socket = /tmp/mysql.sock
mysql
MySQL Support | enabled |
---|---|
Active Persistent Links | 0 |
Active Links | 0 |
Client API version | 5.0.77 |
MYSQL_MODULE_TYPE | external |
MYSQL_SOCKET | /var/lib/mysql/mysql.sock |
MYSQL_INCLUDE | -I/usr/include/mysql |
MYSQL_LIBS | -L/usr/lib64/mysql -lmysqlclient |
Directive | Local Value | Master Value |
---|---|---|
mysql.allow_local_infile | On | On |
mysql.allow_persistent | On | On |
mysql.connect_timeout | 60 | 60 |
mysql.default_host | no value | no value |
mysql.default_password | no value | no value |
mysql.default_port | no value | no value |
mysql.default_socket | /tmp/mysql.sock | /tmp/mysql.sock |
mysql.default_user | no value | no value |
mysql.max_links | Unlimited | Unlimited |
mysql.max_persistent | Unlimited | Unlimited |
mysql.trace_mode | Off | Off |
mysqli
MysqlI Support | enabled |
---|---|
Client API library version | 5.0.77 |
Active Persistent Links | 0 |
Inactive Persistent Links | 0 |
Active Links | 0 |
Client API header version | 5.0.95 |
MYSQLI_SOCKET | /var/lib/mysql/mysql.sock |
Directive | Local Value | Master Value |
---|---|---|
mysqli.allow_local_infile | On | On |
mysqli.allow_persistent | On | On |
mysqli.default_host | no value | no value |
mysqli.default_port | 3306 | 3306 |
mysqli.default_pw | no value | no value |
mysqli.default_socket | /tmp/mysql.sock | /tmp/mysql.sock |
mysqli.default_user | no value | no value |
mysqli.max_links | Unlimited | Unlimited |
mysqli.max_persistent | Unlimited | Unlimited |
mysqli.reconnect | Off | Off |
原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/1569.html