前几天刚接手一个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/server-system-variables.html

 

# This will be passed to all mysql clients

# It has been reported that passwords should be enclosed with ticks/quotes

# escpecially if they contain "#" chars...

# Remember to edit /etc/mysql/debian.cnf when changing the socket location.

 

# Here is entries for some specific programs

# The following values assume you have at least 32M ram

 

[mysqld_safe]

socket          = /var/run/mysqld/mysqld.sock

nice            = 0

 

[mysqld]

#

# * Basic Settings

#

user            = mysql

pid-file        = /var/run/mysqld/mysqld.pid

socket          = /var/run/mysqld/mysqld.sock

port            = 3306

basedir         = /usr

datadir         = /var/lib/mysql

tmpdir          = /tmp

lc-messages-dir = /usr/share/mysql

skip-external-locking

log_bin        =  mylnx12_bin

server_id      = 0

character-set-server=utf8mb4

collation-server=utf8mb4_general_ci

 

#

# Instead of skip-networking the default is now to listen only on

# localhost which is more compatible and is not less secure.

bind-address            = 10.21.6.7

#

# * Fine Tuning

#

key_buffer_size         = 16M

max_allowed_packet      = 100M

thread_stack            = 192K

thread_cache_size       = 8

# This replaces the startup script and checks MyISAM tables if needed

# the first time they are touched

myisam-recover-options  = BACKUP

#max_connections        = 100

#table_cache            = 64

#thread_concurrency     = 10

#

# * Query Cache Configuration

#

query_cache_limit       = 1M

query_cache_size        = 16M

#

# * Logging and Replication

#

# Both location gets rotated by the cronjob.

# Be aware that this log type is a performance killer.

# As of 5.1 you can enable the log at runtime!

#general_log_file        = /var/log/mysql/mysql.log

#general_log             = 1

#

# Error log - should be very few entries.

#

log_error = /var/log/mysql/error.log

#

# Here you can see queries with especially long duration

#log_slow_queries       = /var/log/mysql/mysql-slow.log

#long_query_time = 2

#log-queries-not-using-indexes

#

# The following can be used as easy to replay backup logs or for replication.

# note: if you are setting up a replication slave, see README.Debian about

#       other settings you may need to change.

#server-id              = 1

#log_bin                        = /var/log/mysql/mysql-bin.log

expire_logs_days        = 10

max_binlog_size   = 100M

#binlog_do_db           = include_database_name

#binlog_ignore_db       = include_database_name

#

# * InnoDB

#

# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.

# Read the manual for more InnoDB related options. There are many!

#

# * Security Features

#

# Read the manual, too, if you want chroot!

# chroot = /var/lib/mysql/

#

# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".

#

# ssl-ca=/etc/mysql/cacert.pem

# ssl-cert=/etc/mysql/server-cert.pem

#: ssl-key=/etc/mysql/server-key.pem

Ubuntu下面MySQL的参数文件my.cnf浅析的更多相关文章

  1. MySQL服务读取参数文件my.cnf的规律研究探索

    在MySQL中,它是按什么顺序或规律去读取my.cnf配置文件的呢?其实只要你花一点功夫,实验测试一下就能弄清楚,下面的实验环境为5.7.21 MySQL Community Server.其它版本如 ...

  2. 【查阅】mysql配置文件/参数文件重要参数笔录(my.cnf)

    持续更新,积累自己对参数的理解 [1]my.cnf参数 [client]port = 3306socket = /mysql/data/3306/mysql.sockdefault-character ...

  3. 一个生产可用的mysql参数文件my.cnf

    [client]#客户端选项设置#设置客户端和连接字符集default_character_set = utf8port = 3306socket = /opt/mysql-5.6.24/tmp/my ...

  4. MySQL 5.6.20-enterprise-commercial的参数文件位置问题

    今天在折腾MySQL的参数文件时,突然发现MySQL 5.6.20-enterprise-commercial-advanced-log这个版本数据库的参数文件my.cnf的位置有点奇怪,如下所示: ...

  5. MYSQL数据库的参数文件

    参数文件:告诉MySQL实例启动时在哪里可以找到数据库文件,并且指定某些初始化参数,这些参数定义了某种内存结构的大小等设置,还会介绍各种参数的类型. 参数文件 当MySQL实例启动时,MySQL会先去 ...

  6. 记录一次ubuntu安装mysql,远程无法登录问题的解决历程

    进入ubuntu的mysql配置文件 sudo vim debian.cnf [client] host = localhost user = debian-sys-maint password = ...

  7. MySQL参数文件位置

    对于linux/unix: mysql --help|grep my.cnf   /etc/my.cnf, /etc/mysql/my.cnf, /usr/local/etc/my.cnf, ~/.m ...

  8. Ubuntu安装mysql之后,编译找不到头文件

    解决Ubuntu安装mysql之后找不到mysql.h问题   安装: sudo apt-get install libmysqlclient-dev   编译: gcc test.c -o test ...

  9. MySQL参数文件及参数修改方法

    MySQL参数文件: MySQL数据库初始化参数由参数文件来设置,如果没有设置参数文件,mysql就按照系统中参数的默认值来启动. 在windows和linux上,参数文件可以被放在多个位置,数据库启 ...

随机推荐

  1. [Swift]LeetCode728. 自除数 | Self Dividing Numbers

    A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is ...

  2. [Swift]LeetCode901. 股票价格跨度 | Online Stock Span

    Write a class StockSpanner which collects daily price quotes for some stock, and returns the span of ...

  3. iOS学习——图片压缩到指定大小以内

    一.图片压缩简述 在我们开发过程中,有可能会遇到拍照.或者从相册中选择图片,要么单选或者多选,然后上传图片到服务器,一般情况下一张图片可能3-4M,如果类似微信朋友圈上传9张图片大约是 35M左右,如 ...

  4. Xapian的内存索引

    关键字:xapian.内存索引 xapian除了提供用于生产环境的磁盘索引,也提供了内存索引(InMemoryDatabase).内存索引.我们可以通过观察内存索引的设计,来了解xapian的设计思路 ...

  5. SCOI2019 退役记

    退役了.D2没有翻盘,愉快出队,文化课见. 19年4月14日:某校第一届的最后一名OIer退出竞赛. 留坑. 万一退役失败了呢

  6. java代码之美(1)---Lambda

    Lambda 一.概述 1.什么是Lambda表达式 Lambda 表达式是一种匿名函数,简单地说,它是没有声明的方法,也即没有访问修饰符.返回值声明和名字. 它可以写出更简洁.更灵活的代码.作为一种 ...

  7. 高可用Eureka注册中心配置说明(双机部署)

    目  录 1. 高可用EureKa注册中心示意图 2. Eureka实例相互注册配置 3. 微服务注册到Eureka配置 4. 启动步骤及配置成功检查 5. 说明事项 1. 高可用EureKa注册中心 ...

  8. 构造方法、封装、关键字(this、static)和代码块的介绍

    1.构造方法 1.1 构造方法与成员方法的区别 构造方法分为无参构造和有参构造,其中有参构造方法和无参构造方法为方法的重载关系. 构造方法在初始化一个类的对象时进行调用,它没有返回值,方法名与类名相同 ...

  9. Real Developer 应该参加的硬核竞赛来了!

    本文由云+社区发表 Labs Contest 竞赛简介 君君这次又来搞大事情啦,在 Function As A Service,Serverless,PaaS 大行其道的今天,你是否已经忘记了自己动手 ...

  10. -1-5 java 多线程 概念 进程 线程区别联系 java创建线程方式 线程组 线程池概念 线程安全 同步 同步代码块 Lock锁 sleep()和wait()方法的区别 为什么wait(),notify(),notifyAll()等方法都定义在Object类中

     本文关键词: java 多线程 概念 进程 线程区别联系 java创建线程方式 线程组 线程池概念 线程安全 同步 同步代码块 Lock锁  sleep()和wait()方法的区别 为什么wait( ...