有Ubuntu中MySQL的参数文件my . cnf中所做什么用

  介绍

这篇文章主要介绍Ubuntu中MySQL的参数文有件my . cnf中所做什么用,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

<强>前言

对于MySQL的理解,我认为很多性能优化工作,主从主主复制都是在调整参数,来适应不同时期不同数量级的数据。

故、理解透里彻my . cnf中所做的参数是永恒的话题,只有理解透彻了参数设置,才能在某些方面对数据库进行调优。

前几天刚接手一个MySQL数据,操作系统为Ubuntu 16.04.5 LTS,,数据库版本为5.7.23-0ubuntu0.16.04.1(恰当的方式安装的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 偏好,,my.cnf,, MYSQL_TCP_PORT美元,/etc/my.cnf /etc/mysql/my.cnf  ~/.my.cnf    root@mylnx12: ~ #, mysqld ——verbose ——help  |, grep  -A  1, & # 39; Default 选项# 39;   Default  options 断开连接;read 得到,following  files 拷贝,given 顺序:/etc/my.cnf /etc/mysql/my.cnf  ~/.my.cnf

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

root@mylnx12: ~ #, ls  -lrt 。/etc/选择/my . cnf中所做   lrwxrwxrwx  1, root  root  20, Sep  28, 16:28 /etc/选择/my.cnf →,/etc/mysql/mysql.cnf

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

root@mylnx12: ~ #, cat /var/lib/dpkg。/选择/my . cnf中所做   汽车/etc/mysql/my.cnf   ,/etc/mysql/my.cnf.fallback   One hundred./etc/mysql/mysql.cnf   200年

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

root@mylnx12: ~ #, cat 。/etc/mysql/my . cnf中所做   #   #,从而MySQL  database  server  configuration 文件。   #   #,你还要copy 却;能够用one :   #,安康;“/etc/mysql/my.cnf",用set  global 选项,   #,安康;“~/.my.cnf"用set  user-specific 选项。   #,   #,One 还要use  all  long  options  that 从而program 支持。   #,Run  program  with ——help 用get  a  list  of  available  options 以及   #,——print-defaults 用阅读which  it  would  actually  understand 以及使用。   #   #,For  explanations 看到   #,http://dev.mysql.com/doc/mysql/en/server-system-variables.html   ,   #   #,*,重要的是:,Additional  settings  that 还要override  those 得到却;能够文件!   #,,,files  must 最终获得with  & # 39; .cnf& # 39;,, otherwise  # 39;却ll  be 忽略。   #   ,   ! 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 “轻轨   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   #   #,从而MySQL  database  server  configuration 文件。   #   #,你还要copy 却;能够用one :   #,安康;“/etc/mysql/my.cnf",用set  global 选项,   #,安康;“~/.my.cnf"用set  user-specific 选项。   #,   #,One 还要use  all  long  options  that 从而program 支持。   #,Run  program  with ——help 用get  a  list  of  available  options 以及   #,——print-defaults 用阅读which  it  would  actually  understand 以及使用。   #   #,For  explanations 看到   #,http://dev.mysql.com/doc/mysql/en/server-system-variables.html   ,   #,却;能够will  be  passed 用all  mysql 客户   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

有Ubuntu中MySQL的参数文件my . cnf中所做什么用