Linux查看MySQL配置文件路径及相关配置
(1)關(guān)于配置文件路徑
有時(shí)候,我發(fā)現(xiàn)雖然嘗試修改了配置文件的一些變量,但是并沒(méi)有生效。后來(lái)才發(fā)現(xiàn)原來(lái)是因?yàn)樾薷牡奈募⒎荕ySQL服務(wù)器讀取的配置文件。
如果不清楚MySQL當(dāng)前使用的配置文件路徑,可以嘗試這樣查看:
?
?
復(fù)制代碼
或者是執(zhí)行:
?
mysql --verbose --help|grep -A 1 'Default options'?
復(fù)制代碼
[mysql@linuxtest ~]$ mysqld --verbose --help|grep -A 1 'Default options'2015-12-01 17:23:56 0 [Note] mysqld (mysqld 5.6.27-75.0-log) starting as process 6858 ...
2015-12-01 17:23:56 6858 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 10005)
2015-12-01 17:23:56 6858 [Warning] Buffered warning: Changed limits: max_connections: 214 (requested 2000)
2015-12-01 17:23:56 6858 [Warning] Buffered warning: Changed limits: table_open_cache: 400 (requested 2000)
2015-12-01 17:23:56 6858 [Note] Plugin 'FEDERATED' is disabled.
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
2015-12-01 17:23:56 6858 [Note] Binlog end
2015-12-01 17:23:56 6858 [Note] Shutting down plugin 'CSV'
2015-12-01 17:23:56 6858 [Note] Shutting down plugin 'MyISAM' [mysql@linuxtest ~]$ mysql --verbose --help|grep -A 1 'Default options'
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
從上圖可以看出, 服務(wù)器首先會(huì)讀取/etc/my.cnf文件,如果發(fā)現(xiàn)該文件不存在,再依次嘗試從后面的幾個(gè)路徑進(jìn)行讀取。
(2)關(guān)于配置文件配置項(xiàng)分段
配置文件my.cnf通常會(huì)分成好幾部分,如[client],[mysqld], [mysql]等等。MySQL程序通常是讀取與它同名的分段部分,例如服務(wù)器mysqld通常讀取[mysqld]分段下的相關(guān)配置項(xiàng)。如果配置項(xiàng)位置不正確,該配置是不會(huì)生效的。
(3)關(guān)于全局變量
另外,如果想查看MySQL的一些全局變量設(shè)置,在非登錄并有權(quán)限情況下可以這樣查看: mysqladmin variables -p,
這個(gè)操作也就相當(dāng)于登錄時(shí)使用命令 show global variables;
?
總結(jié)
以上是生活随笔為你收集整理的Linux查看MySQL配置文件路径及相关配置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: python源码剖析_Python源码剖
- 下一篇: 开启Mysql远程登录账号