当前位置:网站首页> MySQL数据库配置信息查看与修改方法详解
MySQL数据库配置信息查看与修改方法详解
2022-06-23 21:49:00 【1024问】
摘要
查看
查看数据基本信息
查询sql_mode
查看在配置文件中定义的变量
查看MySQL的服务当前运行时的变量
查看MySQL默认认证方式
修改MySQL的系统变量
根据变量修改的方式
根据变量的生效范围
总结
摘要当在不同团队间使用MySQL数据库时,最好是保证数据库的配置信息是一致的,否则会因为不同开发同事的SQL规范不一样,导致出现一些不必要的SQL问题;
本篇博客,主要记录如何查看数据的配置信息,及相关解释。
查看查看数据基本信息查看版本
查看版本select version();显示所有可用的字符集;SHOW CHARACTER SET;只显示包含utf8的字符集;SHOW CHARACTER SET LIKE '%utf8%';显示所有的校对规则;SHOW COLLATION;只显示包含utf8的校对规则;SHOW COLLATION LIKE '%utf8%';查询sql_modeselect @@global.sql_mode;select @@sql_mode;确保一致,否则容易出问题;
查看在配置文件中定义的变量mysqld --help --verbose查看MySQL的服务当前运行时的变量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';显示MySQL所有的系统变量
SHOW VARIABLES;常用查询
查个别信息,通过like过滤:
show variables like '%datadir%';show variables like '%basedir%';SHOW VARIABLES LIKE 'character%';SHOW VARIABLES LIKE 'collation_%';是否大小写敏感
show Variables like '%table_names';lower_case_table_names=0 区分大小写
lower_case_table_names=1 表示不区分大小写
如何修改?
注意:
mysql 8.0以前,可以通过,先停止mysql服务,再修改配置文件(如lower_case_table_names=1),再重启mysql服务的方式来修改;
mysql8.0 要求我们不能在initialize之后再更改lower_case_table_names 的值,也就是说,再通过更改 my.cnf 文件是不管用的。所以需要删除原来的所有数据,我的数据目录是在/user/local/mysql/data/,进入到该目录进行删除,默认的路径为:/var/lib/mysql 删除该路径下的所有文件即可
查看MySQL默认认证方式show global variables like '%default_auth%';也支持修改。详见下面修改的章节。
举例,下面是静态修改:
# vi /etc/my.cnf[mysqld]default_authentication_plugin = mysql_native_password修改MySQL的系统变量根据变量修改的方式动态变量:可以在MySQL运行时调整其指,并立即生效;
例如:
set global sort_buffer_size=value静态变量:需要在配置文件中修改,重启服务后生效;例如:/etc/my.cnf
根据变量的生效范围全局变量:服务级别的设定,对整个服务生效,所有回话,当时已经连接的不生效,重新连接才生效;
例如:
set global sort_buffer_size=value会话变量:仅对当前会话生效,其他会话和新会话不受影响;会话结束值即销毁;
例如:
set session sort_buffer_size=value总结到此这篇关于MySQL数据库配置信息查看与修改的文章就介绍到这了,更多相关MySQL配置信息查看修改内容请搜索软件开发网以前的文章或继续浏览下面的相关文章希望大家以后多多支持软件开发网!
边栏推荐
- MySQL highly available version 1c1g exclusive cloud database value-added special offers!
- How to set the website construction title bar drop-down
- 5 minutes to explain what is redis?
- December 14, 2021: rebuild the queue according to height. Suppose there's a bunch of people out of order
- Low code helps live e-commerce bring goods into the manufacturing industry, impacting the traditional supply chain model of the factory
- Micro build low code tutorial - variable definition
- Error message - Customizing incorrectly maintained – in transaction code ML81N
- What is the was fortress server restart was command? What are the reasons why was could not be restarted?
- Targeted, real-time audio and video optimization in remote control
- Go language core 36 lectures (go language practice and application 25) -- learning notes
猜你喜欢

在宇宙的眼眸下,如何正确地关心东数西算?

Why is only one value displayed on your data graph?

Opengauss Developer Day 2022 was officially launched to build an open source database root community with developers

游戏安全丨喊话CALL分析-写代码

蚂蚁获FinQA竞赛冠军,在长文本数值推理AI技术上取得突破

Pourquoi une seule valeur apparaît - elle sur votre carte de données?

openGauss Developer Day 2022正式开启,与开发者共建开源数据库根社区

SAVE: 软件分析验证和测试平台

解密抖音春节红包背后的技术设计与实践

In the eyes of the universe, how to correctly care about counting East and West?
随机推荐
游戏安全丨喊话CALL分析-写代码
运维故障经历分享
How to transfer files from the local fortress server
How does H5 communicate with native apps?
CS1.6 service startup tutorial
Role of API service gateway benefits of independent API gateway
Use elastic security to detect the vulnerability exploitation of cve-2021-44228 (log4j2)
What is the API gateway architecture? What are the common gateway types?
2008R2 CFS with NFS protocol
How does the fortress machine view the account assigned by the server? What are the specific steps?
[tcapulusdb knowledge base] insert data example (TDR table)
sql server常用sql
How to set the search bar of website construction and what should be paid attention to when designing the search box
為什麼你的數據圖譜分析圖上只顯示一個值?
Huawei hardware configuration command, recommended collection
Source code analysis of jmeter5.1 core class testcompiler
Shell automatically obtains hardware information
AAAI 2022 | Tencent Youtu 14 papers were selected, including image coloring, face security, scene text recognition and other frontier fields
API gateway monitoring function the importance of API gateway
How to use FTP to upload websites to the web