当前位置:网站首页> 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配置信息查看修改内容请搜索软件开发网以前的文章或继续浏览下面的相关文章希望大家以后多多支持软件开发网!
边栏推荐
- 2008R2 CFS with NFS protocol
- 解密抖音春节红包背后的技术设计与实践
- Grpc: quickly configure the general API to obtain process meta information
- Kubecon2021 video collection
- How to build a business analysis system
- How many times can the server address and fortress address be entered before the connection is successful? Why did the connection fail?
- Advantages of micro service registry Nacos over Eureka
- The old CVM of Tencent cloud is migrated to the new CVM, and the IP remains unchanged
- Server classification of hardware knowledge (2)
- First talk about the necessary skills of Architecture
猜你喜欢

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

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

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

Hackinglab penetration test question 8:key can't find it again

应用实践 | Apache Doris 整合 Iceberg + Flink CDC 构建实时湖仓一体的联邦查询分析架构

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

為什麼你的數據圖譜分析圖上只顯示一個值?

Slsa: accelerator for successful SBOM

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

In the eyes of the universe, how to correctly care about counting East and West?
随机推荐
How does the fortress remote login server operate? What is the application value of Fortress machine?
How does H5 communicate with native apps?
AAAI 2022 | Tencent Youtu 14 papers were selected, including image coloring, face security, scene text recognition and other frontier fields
Opengauss Developer Day 2022 was officially launched to build an open source database root community with developers
2008R2 CFS with NFS protocol
Advantages of micro service registry Nacos over Eureka
Redis6.x.x build rediscluster cluster
应用实践 | Apache Doris 整合 Iceberg + Flink CDC 构建实时湖仓一体的联邦查询分析架构
How to shut down the server in the fortress machine? What other operations can the fortress machine perform?
Go language core 36 lectures (go language practice and application 25) -- learning notes
How to set dynamic background for website construction what are the benefits of dynamic background
混沌工程,了解一下
Go build command (go language compilation command) complete introduction
WordPress plugin wpschoolpress 2.1.16 -'multiple'cross site scripting (XSS)
SAP mm initial service purchase order
Using nodejs and Tencent cloud API to identify invoices
openGauss Developer Day 2022正式开启,与开发者共建开源数据库根社区
Tcapulusdb Jun · industry news collection
Batch production of plant hangtag
Server classification of hardware knowledge (2)