You cannot connect to the server through '/tmp/mysql.sock ', and the PHP standard configuration is using '/tmp/mysql.sock ', but some MySQL installation methods will
Mysql.sock in/var/lib/mysql.sock or whatever, you can fix it by modifying the/etc/my.conf file.
First of all, mysqld can't start,
I modified the value of the socket below the [mysqld] option through VIM/ETC/MY.CNF
Socket=/var/lib/mysql/mysql.sock
Ok,mysqld can be activated.
Next, the MySQL boot is not, again, VIM/ETC/MY.CNF, added the following script:
[MySQL]
Socket=/var/lib/mysql/mysql.sock
Then, mysqladmin not start, or the same, under [mysqladmin] The socket value is set to the same path
OK, it's ready to start.
Finally, when connecting with PHP, this problem occurs again.
Can ' t connect to the local MySQL server through socket '/tmp/mysql.sock ' (2)
The first thing I thought of was, in/etc/php.ini to modify the value of Mysql.default_socket, in this file, about Mysql.default_socket's
The description of the value is like this,
; Default socket name for the local MySQL connects. If empty, uses the built-in MySQL defaults.
This value is empty at first, which means that if we don't change it, PHP will use the default values built into MySQL
So, I modified the value and set it to:
Mysql.default_socket=/var/lib/mysql/mysql.sock
Then I restart Apache, the result is invalid; reboot system, invalid result
I'm fire, PHP has to go to connect/tmp/mysql.sock, but my system is not in the path of this file, then I will give you chain
And then I did the following,
Ln-s/var/lib/mysql/mysql.sock/tmp/mysql.sock
How to Protect "/tmp/mysql.sock" from being deleted
If you have this problem, in fact anyone can delete the MySQL communication socket "/tmp/mysql.sock", on most versions of UNIX, you can
Protect your "/tmp" file system by setting the sticky (t) bit. Log in as root and do the following:
shell> chmod +t/tmp
This will protect your "/tmp" file system so that files can only be deleted by their owner or superuser (root).
You can perform ls-ld/tmp check if the sticky bit is set, if the last permission bit is T, the bit is set.