自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

MySQL如何找到使用的是哪個(gè)配置文件?

數(shù)據(jù)庫 MySQL
一個(gè)正在運(yùn)行的MySQL實(shí)例,如何查看對應(yīng)的配置文件用的是哪一個(gè)?如果存在多個(gè)文件,生效的順序是怎么樣的?

1、方法一

首先可以先選擇查看MySQL進(jìn)程信息來判斷使用了哪個(gè)配置文件,例如:

ps -aux|grep mysqld
root     25628  0.0  0.0 112828   988 pts/0    S+   19:13   0:00 grep --color=auto mysqld
root     27503  0.0  0.0 113416  1660 ?        S     2023   0:00 /bin/sh /usr/local/mysql5.7/bin/mysqld_safe --defaults-file=/data/mysql/mysql3306/etc/my.cnf
mysql    28697  0.1 38.3 6168644 689056 ?      Sl    2023 120:07 /usr/local/mysql5.7/bin/mysqld --defaults-file=/data/mysql/mysql3306/etc/my.cnf --basedir=/usr/local/mysql5.7 --datadir=/data/mysql/mysql3306/data --plugin-dir=/usr/local/mysql5.7/lib/mysql/plugin --user=mysql --log-error=/data/mysql/mysql3306/logs/mysqld.error --open-files-limit=65535 --pid-file=/data/mysql/mysql3306/tmp/mysqld.pid --socket=/data/mysql/mysql3306/tmp/mysql.sock --port=3306

圖片

結(jié)果中有--defaults-file=/data/mysql/mysql3306/etc/my.cnf,即該實(shí)例所使用的配置文件信息。

2、方法二

有的時(shí)候,如果不是不帶defaults-file參數(shù)啟動(dòng)數(shù)據(jù)庫時(shí),查看進(jìn)程信息的結(jié)果中是沒有對應(yīng)的配置文件信息。例如:

ps -aux|grep mysqld
mysql    1891850  1.2  2.2 2308948 366080 ?      Ssl   2023 1355:28 /usr/sbin/mysqld
root     3183979  0.0  0.0  12316  2272 pts/9    S+   19:09   0:00 grep --color=auto mysqld

圖片

此時(shí),如果使用的是MySQL8.0,可以登錄到數(shù)據(jù)庫后,通過查詢對應(yīng)視圖performance_schema.variables_info來查看。例如:

mysql> SELECT  variable_path,COUNT(*) FROM performance_schema.variables_info WHERE variable_path<>''  GROUP BY variable_path;
+------------------------------------+----------+
| variable_path                      | COUNT(*) |
+------------------------------------+----------+
| /etc/mysql/mysql.conf.d/mysqld.cnf |        6 |
+------------------------------------+----------+

此時(shí)可以確定其配置文件信息。

PS:有時(shí)會(huì)查詢到多個(gè)配置文件,可以思考一下為何如此設(shè)計(jì)。

如果使用的是MySQL8.0之前的版本,需要在下一步的順序中尋找。

3、配置文件生效順序

如果存在多個(gè)配置文件,它們通常是以下的優(yōu)先級順序生效:

  • 系統(tǒng)級配置文件:位于 /etc/my.cnf 或 C:\Program、Data\MySQL\MySQL Server x.x\my.ini。這是默認(rèn)的主配置文件,包含全局設(shè)置。
  • 配置文件目錄中的其他文件:MySQL配置文件目錄中的其他文件,通常在 /etc/mysql/conf.d/ 或 C:\ProgramData\MySQL\MySQL Server x.x\conf.d\。
  • 這些文件允許模塊化配置,會(huì)按照文件名的字母順序合并。
  • 用戶級配置文件:位于用戶的主目錄,如 ~/.my.cnf 或 %APPDATA%\MySQL\.my.cnf。這里的配置會(huì)覆蓋系統(tǒng)級配置。
  • 命令行參數(shù):在啟動(dòng)數(shù)據(jù)庫實(shí)例時(shí)可以指定defaults-file或者指定對應(yīng)的datadir等參數(shù),這些將覆蓋之前的所有配置,優(yōu)先級最高。
責(zé)任編輯:姜華 來源: 數(shù)據(jù)庫干貨鋪
相關(guān)推薦

2010-02-03 09:19:31

Python模塊

2009-06-08 16:44:00

Struts配置文件

2019-11-22 10:00:53

ICC配置文件Windows 10

2010-12-27 14:59:31

Outlook 配置文

2021-07-05 12:09:58

Python編程語言

2022-11-10 09:05:18

Lua配置文件

2020-12-15 08:03:57

Mybatis配置文件

2009-11-05 10:30:41

WCF Address

2010-01-07 17:16:19

Ubuntu MySQ

2011-03-25 17:13:37

Nagios配置文件

2011-02-25 16:39:34

proftpd配置文件

2021-11-07 14:00:16

JekyllBashAPI后端

2021-03-12 08:00:00

Kubernetes工具

2021-07-08 21:19:04

BashLinux

2011-01-19 14:00:21

2011-01-13 16:27:26

Linux配置文件

2010-08-25 10:24:55

DHCP配置文件

2011-03-23 15:13:08

Nagios配置文件

2011-03-03 13:16:32

Proftpd配置文件

2010-11-26 14:11:33

SQL Server
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號