MySQL parameter learning (a)

(1) MySQL parameter file my.cnf

MySQL default parameter file location has four, if there are a plurality of parameter files, then the parameter mulching principle Parameter front profile will be later overwritten file.

[root@mysqlserver bin]# mysqld --help -v| grep my.cnf /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf

DBA can also custom parameter file location "defaults_file", so that the system does not read the default configuration file.

[mysql@mysqlserver etc]$ mysql --help |grep defaults-file --defaults-file=# 
Only read default options from the given file #. 

How to use the parameter file to customize it?

cd /usr/local/mysql
 bin/mysqld --defaults-file=/opt/mysql/mysql/etc/my.cnf  --initialize --user=mysql

 

(2) MySQL parameter configuration

MySQL parameters from the scope of either Class 2: global and the session, from the type of modification can be divided into: the parameters can be modified and read-only, read-only non-online users can modify the parameters for read-only parameters, configuration files can be modify and restart.

(2.1) View parameter settings

show variables like '%log%';

or:

- the session-level parameters 
MySQL >  the SELECT  @@ autocommit ;
 + - ------------ + 
|  @@ autocommit  | 
+ - ------------ + 
|             0  | 
+ - ------------ + 
1 Row in  the SET ( 0.00 sec) 

- , Ltd. Free Join level parameters 
MySQL >  the SELECT  @@, Ltd. Free Join .autocommit;
 + - ------- + ------------ 
|  @@, Ltd. Free Join .autocommit | 
+ - ------------------- + 
|                   1 |
+---------------------+
1 row in set (0.00 sec)

(2.2) to modify parameters

- Session parameter modification 
MySQL >  SET the autocommit = 0 ; 

- global parameter modification 
MySQL >  SET Global the autocommit =  0 ;

Modifications session-level parameters, valid only for the current session; to modify the global parameters for subsequent newly established connection is active. But after the restart the database, the value of the parameter will become before the amendment, which change all the parameters are not persistent, or come after the restart in the configuration file. If you want to keep the parameters lasting and effective, we need to modify the parameter file my.cnf and restart the database.

Guess you like

Origin www.cnblogs.com/lijiaman/p/12153347.html