1. 程式人生 > >mysql8學習手冊第四部分:mysql配置檔案的使用和高階配置

mysql8學習手冊第四部分:mysql配置檔案的使用和高階配置


第四章:Configuring Mysql

  • Using config file
  • Using global and session variables
  • Using parameters with startup script
  • Configuring the parameters
  • Changing the data directory

mysql有兩種引數:Static(重啟生效)和Dynamic(不用重啟即可生效)

mysql變數設定:

  1. Config file

  2. Startup script

  3. Using SET command

  4. Using config file
    The default config file is /etc/my.cnf (on Red Hat and CentOS systems) and /etc/mysql/my.cnf (Debian systems)

mysql配置參考樣例:

[mysqld] <---section name
<parameter_name> = <value> <---parameter values
[client]
<parameter_name> = <value>
[mysqldump]
<parameter_name> = <value>
[mysqld_safe]
<parameter_name> = <value>
[server]
<parameter_name> = <value>
  • [mysql] : Section is read by the mysql command-line client
  • [client] : Section is read by all connectingclients (including mysql cli )
  • [mysqld] : Section is read by the mysql server
  • [mysqldump] : The section is read by the backuputility called mysqldump
  • [mysqld_safe] : Read by the mysqld_safe process(MySQL Server Startup Script)
  1. Using global and session variables

Global: Applies to all the new connections
Session: Applies only to the current connection

SET GLOBAL long_query_time = 1;
SET PERSIST long_query_time = 1;
SET @@persist.long_query_time = 1;
SET SESSION long_query_time = 1;