麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 數據庫 > MySQL > 正文

Ubuntu中MySQL的參數文件my.cnf示例詳析

2024-07-25 19:09:06
字體:
來源:轉載
供稿:網友

前言

對于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.cnfroot@mylnx12:~# locate my.cnf/etc/alternatives/my.cnf/etc/mysql/my.cnf/etc/mysql/my.cnf.fallback/var/lib/dpkg/alternatives/my.cnfroot@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.cnflrwxrwxrwx 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.cnfauto/etc/mysql/my.cnf /etc/mysql/my.cnf.fallback100/etc/mysql/mysql.cnf200

光從上面這些信息,我們還看不出/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 -lrttotal 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.cnfroot@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.socknice      = 0 [mysqld]## * Basic Settings#user      = mysqlpid-file    = /var/run/mysqld/mysqld.pidsocket     = /var/run/mysqld/mysqld.sockport      = 3306basedir     = /usrdatadir     = /var/lib/mysqltmpdir     = /tmplc-messages-dir = /usr/share/mysqlskip-external-lockinglog_bin    = mylnx12_binserver_id   = 0character-set-server=utf8mb4collation-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     = 16Mmax_allowed_packet   = 100Mthread_stack      = 192Kthread_cache_size    = 8# This replaces the startup script and checks MyISAM tables if needed# the first time they are touchedmyisam-recover-options = BACKUP#max_connections    = 100#table_cache      = 64#thread_concurrency   = 10## * Query Cache Configuration#query_cache_limit    = 1Mquery_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.logexpire_logs_days    = 10max_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

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,如果有疑問大家可以留言交流,謝謝大家對VeVb武林網的支持。


注:相關教程知識閱讀請移步到MYSQL教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 日日草夜夜 | 久久靖品 | 羞羞网站 | 性少妇chinesevideo | 久久久久久久久久久久久国产精品 | 精品国产99久久久久久宅男i | 国产激情视频在线 | 亚洲成人欧美在线 | 2023av在线视频 | 日韩欧美精品电影 | 圆产精品久久久久久久久久久 | av免费提供 | 激情视频导航 | 国产在线精品一区二区三区 | 国产成年人网站 | 成年人黄色免费网站 | 午夜视频在线免费 | 久久精品国产亚洲7777 | 国产18视频 | 粉嫩粉嫩一区二区三区在线播放 | 精国品产一区二区三区有限公司 | 久久精品视频69 | 日韩大片在线永久观看视频网站免费 | 国产一区国产二区在线观看 | av在线日韩 | 精品国产一区二区三区在线 | 欧美成人午夜 | 久久精品一区二区三区不卡牛牛 | 成人不卡免费视频 | 91情侣在线偷精品国产 | 叶子楣成人爽a毛片免费啪啪 | 国产乱淫av | 国产二区三区在线播放 | 久久免费观看一级毛片 | 欧美一级黄色录相 | 精品国产呦系列在线看 | 久久久久免费精品国产小说色大师 | 国产99久久久久 | 毛片大全免费 | 精品久久久一二三区播放播放播放视频 | 中文字幕欧美在线 |