mysql配置文件/etc/my.cnf之选项组[client]与[group]之间都有socket选项,其区别分析

[client]是mysql客户端执行的时候才会加载的选项组,如mysql命令,是mysql客户端的其中之一,我们在[client]中配置的变量值是mysql命令执行时候的相关命令选项的默认值。

[client]
socket=/var/lib/mysql/mysql.sock

如上所示,当我们执行mysql的时候,如果没有带–socket选项参数,那么默认该选项的值就是我们在配置选项组[client]中配置的socket值。

[root@localhost ~]# mysql --socket=/var/lib/mysqlnow.sock --help --verbose |grep sock
  --protocol=name     The protocol to use for connection (tcp, socket, pipe,
  -S, --socket=name   The socket file to use for connection.
                      The buffer size for TCP/IP and socket communication.
socket                            /var/lib/mysqlnow.sock
[root@localhost ~]# mysql  --help --verbose |grep sock #可见如果我们不显示指定socket选项参数,那么默认是配置文件中[client]组中的socket的参数值
  --protocol=name     The protocol to use for connection (tcp, socket, pipe,
  -S, --socket=name   The socket file to use for connection.
                      The buffer size for TCP/IP and socket communication.
socket                           /var/lib/mysql/mysql.sock
[root@localhost ~]#

[mysqld]或[server]或[mariadb]组中的socket参数,是mysqld命令执行的时候才会加载的选项组。比如mysqld命令,我们在[mysqld]等组中配置的变量值是mysqld命令执行时候的相关命令选项的默认值。

[mysqld]
socket=/var/lib/mysql/mysqlserver.sock
[root@localhost ~]# mysqld --socket=/var/lib/mysql/mysqlnow.sock --help --verbose |grep sock
200226 16:11:50 [Note] Plugin 'FEEDBACK' is disabled.
                      Buffer length for TCP/IP and socket communication
                      the slave off the socket once the slave connects. Due to
  --socket=name       Socket file to use for connection
socket                                            /var/lib/mysql/mysqlnow.sock
[root@localhost ~]# mysqld --help --verbose |grep sock
200226 16:11:17 [Note] Plugin 'FEEDBACK' is disabled.
                      Buffer length for TCP/IP and socket communication
                      the slave off the socket once the slave connects. Due to
  --socket=name       Socket file to use for connection
socket                                            /var/lib/mysql/mysqlserver.sock

[root@localhost ~]#

关于选项组(option group)的详细配置规则详述,参见地址:https://blog.csdn.net/yaqiang2017/article/details/104518219

你可能感兴趣的:(mysql)