Mysql error-Modify mysql. sock location, mysqlmysql. sock
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 ~
Q: How to change the mysql directory in linux? Is there a lot of documents saying that you want to change the mysqlsock path? Is this required? Is it not affected if it is not changed?
Mysql. by default, sock is in/var/lib/mysql. If the directory has insufficient permissions, mysql cannot run because the file cannot be created. You can add mysql under [mysqld. sock path
Vi/etc/my. cnf
[Mysqld]
Port = 3306
Socket =/var/lib/mysql. sock
...
Mysqlsock is not located in/tmp. How can I fill in the database server when DZ is installed?
Coshep is a case. Another case is that there may be two MYSQL instances in your system, but the my. cnf file is not correctly loaded at startup.
Check whether the datadir position in my. cnf is correct.