确定MySQL在Linux系统中配置文件的位置

确定MySQL在Linux系统中配置文件的位置,第1张

假定确定mysql位于/usr/local/mysql/bin目录

执行如下命令:/usr/local/mysql/bin/mysqld --verbose --help |grep -A 1 'Default options'

可能看到如下信息:

2019-04-14 19:18:23 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled

2019-04-14 19:18:23 0 [Note] mysqld (mysqld 5.6.42) starting as process 14944 ...

2019-04-14 19:18:23 14944 [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/local/mysql/etc/my.cnf ~/.my.cnf

2019-04-14 19:18:23 14944 [Note] Binlog end

2019-04-14 19:18:23 14944 [Note] Shutting down plugin 'MyISAM'

2019-04-14 19:18:23 14944 [Note] Shutting down plugin 'CSV'

上面信息中,etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf给出的几个目录,就是mysql依次查找配置文件的位置。

首先先看看你的mysql在哪,通过which命令

which mysql

显示出目录比如我的是下面这个

/usr/bin/mysql

接下来就可以针对这个目录通过一些命令查看配置文件在哪了,如下

/usr/bin/mysql --verbose --help | grep -A 1 'Default options'

然后在下面会出现一些信息比如我的

Default options are read from the following files in the given order:

/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf

这个信息的意思是:

服务器首先读取的是/etc/mysql/my.cnf文件,如果前一个文件不存在则继续读/etc/my.cnf文件,如若还不存在便会去读~/.my.cnf文件


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/11696945.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-18
下一篇 2023-05-18

发表评论

登录后才能评论

评论列表(0条)

保存