如何查看Linux服务器上mysql配置文件路径

2023-11-22 0 755

本篇文章主要和大家分享一下查看linux服务器上mysql配置文件路径的方法,本文实操记录、绝无水文,如有遗漏或错误欢迎指正。

(1)关于配置文件路径

有时候,我发现虽然尝试修改了配置文件的一些变量,但是并没有生效。后来才发现原来是因为修改的文件并非MySQL服务器读取的配置文件。

如果不清楚MySQL当前使用的配置文件路径,可以尝试这样查看:

 mysqld --verbose --help|grep -A 1 'Default options'

复制代码

或者是执行:

 mysql --verbose --help|grep -A 1 'Default options'

复制代码

[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

从上图可以看出, 服务器首先会读取/etc/my.cnf文件,如果发现该文件不存在,再依次尝试从后面的几个路径进行读取。

(2)关于配置文件配置项分段

配置文件my.cnf通常会分成好几部分,如[client],[mysqld], [mysql]等等。MySQL程序通常是读取与它同名的分段部分,例如服务器mysqld通常读取[mysqld]分段下的相关配置项。如果配置项位置不正确,该配置是不会生效的。

(3)关于全局变量

另外,如果想查看MySQL的一些全局变量设置,在非登录并有权限情况下可以这样查看: mysqladmin variables -p,

这个操作也就相当于登录时使用命令 show global variables;

至此关于Linux系统查看linux服务器上mysql配置文件路径的方法分享结束, 欢迎大家在评论区留言。

以上就是良许教程网为各位朋友分享的Linux系统相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多干货等着你!

本文来源:www.lxlinux.net/1325.html,若引用不当,请联系修改。

相关文章

猜你喜欢
官方客服团队

为您解决烦忧 - 24小时在线 专业服务

  • 0 +

    访问总数

  • 0 +

    会员总数

  • 0 +

    文章总数

  • 0 +

    今日发布

  • 0 +

    本周发布

  • 4975 +

    运行天数

你的前景,远超我们想象