Mysql error-Modify mysql. sock location
Sometimes Mysql. sock location errors may occur in mysql, resulting in the inability to connect to the database.
When an error is reported in mac:
First modify my. cnf
The location is under/etc/my. cnf. If not, modify it under/usr/locate/mysql/my. cnf and copy it to/etc.
To:
[client]socket = /tmp/mysql.sock[mysqld]socket = /tmp/mysql.sock
If there is no [client], add it yourself ~
Then restart the mysql service and open mysql to see if the location has changed ~ Use, view status
mysql Ver 14.14 Distrib 5.6.17, for osx10.7 (x86_64) using EditLine wrapperConnection id:24Current database:Current user:root@localhostSSL:Not in useCurrent pager:lessUsing outfile:''Using delimiter:;Server version:5.6.17 MySQL Community Server (GPL)Protocol version:10Connection:Localhost via UNIX socketServer characterset:utf8Db characterset:utf8Client characterset:utf8Conn. characterset:utf8UNIX socket:/tmp/mysql.sockUptime:15 min 51 sec
If php. ini (the location is/etc/php. ini) is not found, copy a php. ini. default file.
In:
pdo_mysql.default_socket=/tmp/mysql.sockmysql.default_socket = /tmp/mysql.sockmysqli.default_socket = /tmp/mysql.sock
All three are modified ~
Then
sudo apachectl stopsudo apachectl start
You can ~
Check whether mysql. sock has changed under phpinfo ~