设为首页 加入收藏

TOP

Ubuntu下面MySQL的参数文件my.cnf浅析(一)
2018-10-08 10:03:56 】 浏览:236
Tags:Ubuntu 下面 MySQL 参数 文件 my.cnf 浅析

前几天刚接手一个 MySQL 数据,操作系统为Ubuntu 16.04.5 LTS,  数据库版本为 5.7.23-0ubuntu0.16.04.1(APT方式安装的MySQL)。这个操作系统下的 MySQL 的配置文件 my.cnf 很多地方都让人有点不适应(跟之前的 MySQL 环境有些出入,之前都是维护 RHEL、CentOS 等操作系统环境下的 MySQL)。遂研究总结了一下。具体如下所示:

root@mylnx12:~# find / -name "my.cnf"
/etc/alternatives/my.cnf
/etc/mysql/my.cnf
/var/lib/dpkg/alternatives/my.cnf
root@mylnx12:~# locate my.cnf
/etc/alternatives/my.cnf
/etc/mysql/my.cnf
/etc/mysql/my.cnf.fallback
/var/lib/dpkg/alternatives/my.cnf
root@mylnx12:~# mysql --help | grep my.cnf
                      order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf 
root@mylnx12:~#  mysqld --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 ~/.my.cnf

从上面这些信息判断,MySQL 的参数文件为 /etc/mysql/my.cnf, 但是其他几个 my.cnf 又是什么情况呢?

root@mylnx12:~# ls -lrt /etc/alternatives/my.cnf
lrwxrwxrwx 1 root root 20 Sep 28 16:28 /etc/alternatives/my.cnf -> /etc/mysql/mysql.cnf

从上面信息可以看出,/etc/alternatives/my.cnf 其实是一个软连接,指向参数文件 /etc/mysql/mysql.cnf

root@mylnx12:~# cat /var/lib/dpkg/alternatives/my.cnf
auto
/etc/mysql/my.cnf

/etc/mysql/my.cnf.fallback
100
/etc/mysql/mysql.cnf
200

光从上面这些信息,我们还看不出 /var/lib/dpkg/alternatives/my.cnf 与其它配置文件 my.cnf 是什么关系。那么我们先来看看参数文件 /etc/mysql/my.cnf,从下面信息,可以看出 /etc/mysql/my.cnf” 是全局配置,~/.my.cnf” 隐藏文件是个人用户设置。

root@mylnx12:~# cat /etc/mysql/my.cnf
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

但是 /etc/mysql/my.cnf 参数文件下面没有任何参数设置,只看到下面两行设置,表示导入这两个目录里面的配置文件。

!includedir /etc/mysql/conf.d/

 # 表示包含 /etc/mysql/conf.d/ 这个路径下面的配置文件,前提是必须以为 .cnf 为后缀

!includedir /etc/mysql/mysql.conf.d/

# 表示包含 /etc/mysql/mysql.conf.d/ 这个路径下面的配置文件,前提是必须以为 .cnf 为后缀

其实MySQL的相关配置都位于 mysqld.cnf(/etc/mysql/mysql.conf.d/mysqld.cnf)下面。使用相关参数测试了一下,确实都能生效。这种设置确实有点让刚接触的人有点不适应。暂时先总结到此!

root@mylnx12:~# cd /etc/mysql/mysql.conf.d/
root@mylnx12:/etc/mysql/mysql.conf.d# ls -lrt
total 8
-rw-r--r-- 1 root root   21 Feb  4  2017 mysqld_safe_syslog.cnf
-rw-r--r-- 1 root root 3148 Oct  6 23:34 mysqld.cnf
root@mylnx12:/etc/mysql/mysql.conf.d# cat mysqld.cnf
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en
首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Disruptor源码阅读笔记 下一篇Java中JNI的使用(上)

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目