Rechercher dans le manuel MySQL
B.4.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
for RPMs.)
On some versions of Unix, anyone can delete files in the
/tmp
directory 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
/tmp
directory so that files can be
deleted only by their owners or the superuser
(root
). To do this, set the
sticky
bit on the /tmp
directory by logging in as root
and using
the following command:
shell> chmod +t /tmp
You can check whether the sticky
bit is set
by executing ls -ld /tmp
. If the last
permission character is t
, the bit is set.
Another approach is to change the place where the 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:
Specify the path in a global or local option file. For example, put the following lines in
/etc/my.cnf
:[mysqld] socket=/path/to/socket [client] socket=/path/to/socket
Specify a
--socket
option on the command line to mysqld_safe and when you run client programs.Set the
MYSQL_UNIX_PORT
environment variable to the path of the Unix socket file.Recompile MySQL from source to use a different default Unix socket file location. Define the path to the file with the
MYSQL_UNIX_ADDR
option when you run CMake. See Section 2.9.7, “MySQL Source-Configuration Options”.
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
Document created the 26/06/2006, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/mysql-rf-problems-with-mysql-sock.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.