用户可以在配置文件中指定套接字文件的路径,如--socket=/data/mysql/mysql.sock
[root@localhost ~]# mysql -uroot -p123456 -S /data/mysql/mysql.sock
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.0.41-log Source distribution
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| handan |
| monkey |
| mysql |
| test |
+--------------------+
5 rows in set (0.15 sec)
mysql> show variables like 'socket';
+---------------+------------------------+
| Variable_name | Value |
+---------------+------------------------+
| socket | /data/mysql/mysql.sock |
+---------------+------------------------+
1 row in set (0.07 sec)