MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr)- 41.6Mb
PDF (A4)- 41.7Mb
Man Pages (TGZ)- 262.2Kb
Man Pages (Zip)- 372.3Kb
Info (Gzip)- 4.0Mb
Info (Zip)- 4.0Mb
Excerpts from this Manual

B.3.3.6 How to Protect or Change the MySQL Unix Socket File

The default location for the Unix socket file that the server uses for communication with local clients is/tmp/mysql.sock. (For some distribution formats, the directory might be different, such as/var/lib/mysql对rpm)。

On some versions of Unix, anyone can delete files in the/tmpdirectory or other similar directories used for temporary files. If the socket file is located in such a directory on your system, this might cause problems.

On most versions of Unix, you can protect your/tmpdirectory so that files can be deleted only by their owners or the superuser (root). To do this, set thestickybit on the/tmpdirectory by logging in asrootand using the following command:

shell> chmod +t /tmp

You can check whether thestickybit is set by executingls -ld /tmp. If the last permission character ist, the bit is set.

另一种方法是改变的地方server creates the Unix socket file. If you do this, you should also let client programs know the new location of the file. You can specify the file location in several ways:

You can test whether the new socket location works by attempting to connect to the server with this command:

shell> mysqladmin --socket=/path/to/socket version