mysql获取配置文件信息,四种获取MySQL数据库配置文件加载顺序

简介

有时候帮人排查一下MySQL数据库问题的时候,用ps -ef查看MySQL数据库进程的时候,竟然不显示配置的相关信息。

如果想看MySQL数据库的配置,就会一头雾水,于是就特地整理了一下,4种查看当前MySQL数据库加载数据库配置文件的顺序方法。

查看配置文件顺序方法

1.方法一

通过ps -ef查看MySQL数据库进程,一般用二进制包方式启动数据库,会显示。

[mysql@192 ~]$ ps -ef|grep -i mysql

mysql 62843 1 0 Sep05 ? 00:00:00 /bin/sh /u02/mysql/bin/mysqld_safe --defaults-file=/u02/conf/my3308.cnf

mysql 63855 62843 0 Sep05 ? 00:01:50 /u02/mysql/bin/mysqld --defaults-file=/u02/conf/my3308.cnf --basedir=/u02/mysql --datadir=/u02/data/3308 --plugin-dir=/u02/mysql/lib/plugin --log-error=/u02/log/3308/error.log --open-files-limit=65535 --pid-file=/u02/run/3308/mysqld.pid --socket=/u02/run/3308/mysql.sock --port=3308

2.方法二

通过my_print_defaults命令的帮助信息,可以获取当前MySQL数据库版本加载配置文件顺序

[mysql@192 ~]$ my_print_defaults --help|grep -A2 -B2 my.cnf

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

Variables (--variable-name=value)

3.方法三

通过mysqld命令的帮助信息,可以获取当前MySQL数据库版本加载配置文件顺序

[mysql@192 ~]$ /u02/mysql/bin/mysqld --verbose --help|grep -A 1 'Default options'

mysqld: Can't change dir to '/var/lib/mysql/' (Errcode: 2 - No such file or directory)

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

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

4.方法四

通过mysql命令的帮助信息,可以获取当前MySQL数据库版本加载配置文件顺序

[mysql@192 ~]$ /u02/mysql/bin/mysql --help|grep 'my.cnf'

order of preference, my.cnf, $MYSQL_TCP_PORT, built-in

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

以上就是四种获取MySQL数据库加载配置文件顺序的方法,有些时候还是非常的有用。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值