The default location for a UNIX socket file that the server uses to communicate with the local client is/tmp/mysql.sock. This can cause problems because, on some versions of UNIX, anyone can delete files in the/tmp directory.
In most UNIX versions, the/TMP directory can be protected so that the file can only be deleted by all of its or superuser (root users). To do this, log in as the root user and set the sticky bit on the/tmp directory using the following command:
shell> chmod +t /tmp
By performing ls-ld/tmp, you can check to see if a sticky bit is set. If the last license character is "T", it indicates that the sticky bit is set.
Another way is to change the location where the server creates a UNIX socket file. If you do this, you should also let the client program know the location of the file. The ability to specify file locations in several different ways:
Specify the path in the global or local options file. For example, place the following line in file/etc/my.cnf:
[mysqld]
socket=/path/to/socket
[client]
socket=/path/to/socket
When you run the client program, specify the "--socket" option on the command line for Mysqld_safe.
Set the MYSQL_UNIX_PORT environment variable to the path of the UNIX socket file.
Re-compile MySQL from the source code to use a different default UNIX socket file location. When you run configure, define the file path with the--with-unix-socket-path option.
Connect to the server with the following command to test whether the new socket position is working:
shell> mysqladmin --socket=/path/to/socket version