当前位置:网站首页>Detailed explanation of MySQL database configuration information viewing and modification methods

Detailed explanation of MySQL database configuration information viewing and modification methods

2022-06-23 22:54:00 1024 Q

Catalog

Abstract

see

View the basic information of the data

Inquire about sql_mode

View the variables defined in the configuration file

see MySQL The current runtime variables of the service

see MySQL Default authentication method

modify MySQL The system variable of

According to how the variable is modified

According to the effective range of the variable

summary

Abstract

When used across teams MySQL Database time , It is best to ensure that the configuration information of the database is consistent , Otherwise, there will be different development colleagues SQL The norms are different , Cause some unnecessary SQL problem ;

This blog , It mainly records how to view data configuration information , And related explanations .

see View the basic information of the data

View version

View version select version(); Displays all available character sets ;SHOW CHARACTER SET; Show only include utf8 Character set for ;SHOW CHARACTER SET LIKE '%utf8%'; Show all proofing rules ;SHOW COLLATION; Show only include utf8 The rules of proofreading ;SHOW COLLATION LIKE '%utf8%'; Inquire about sql_modeselect @@global.sql_mode;select @@sql_mode;

Make sure there's consistency , Otherwise, it's easy to have problems ;

View the variables defined in the configuration file mysqld --help --verbose see MySQL The current runtime variables of the service SHOW [{GLOBAL|SESSION}] VARIABLES [LIKE ''];SELECT @@{GLOBAL|SESSION}.VARIABLE_NAME;SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME='VARIABLE_NAME';SELECT * FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME='VARIABLE_NAME';

Show MySQL All system variables

SHOW VARIABLES;

Common query

Check individual information , adopt like Filter :

show variables like '%datadir%';show variables like '%basedir%';SHOW VARIABLES LIKE 'character%';SHOW VARIABLES LIKE 'collation_%';

Case sensitive or not

show Variables like '%table_names';

lower_case_table_names=0 Case sensitive

lower_case_table_names=1 Indicates case insensitive

How to modify ?

Be careful :

mysql 8.0 before , Can pass , First stop mysql service , Then modify the configuration file ( Such as lower_case_table_names=1), Restart again mysql Service ;

mysql8.0 Ask us not to be in initialize Change it later lower_case_table_names Value , in other words , And then by changing my.cnf Files don't work . So you need to delete all the original data , My data directory is in /user/local/mysql/data/, Enter the directory to delete , The default path is :/var/lib/mysql Delete all files under this path

see MySQL Default authentication method show global variables like '%default_auth%';

It also supports modifying . See the revised section below for details .

give an example , Here are the static modifications :

# vi /etc/my.cnf[mysqld]default_authentication_plugin = mysql_native_password modify MySQL The system variable of According to how the variable is modified

Dynamic variables : Can be in MySQL Adjust its fingers at runtime , With immediate effect ;

for example :

set global sort_buffer_size=value

Static variables : It needs to be modified in the configuration file , Effective after service restart ; for example :/etc/my.cnf

According to the effective range of the variable

Global variables : Service level setting , Effective for the entire service , All replies , Those already connected at that time do not take effect , Reconnection takes effect ;
for example :

set global sort_buffer_size=value

Session variables : Only valid for the current session , Other conversations and new conversations are not affected ; The end of session value is destroyed ;

for example :

set session sort_buffer_size=value summary

This is about MySQL This is the end of the article on viewing and modifying database configuration information , More about MySQL Please search the previous articles of the software development network or continue to browse the relevant articles below. I hope you can support the software development network in the future !


原网站

版权声明
本文为[1024 Q]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206231844422890.html