最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Ubuntu中MySQL的參數(shù)文件my.cnf示例詳析

 更新時間:2018年10月10日 10:09:18   作者:瀟湘隱者  
這篇文章主要給大家介紹了關(guān)于Ubuntu中MySQL的參數(shù)文件my.cnf的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家學(xué)習(xí)或者使用mysql具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

前言

對于MySQL的理解,我認為很多性能優(yōu)化工作、主從主主復(fù)制都是在調(diào)整參數(shù),來適應(yīng)不同時期不同數(shù)量級的數(shù)據(jù)。

故,理解透徹my.cnf里的參數(shù)是永恒的話題;只有理解透徹了參數(shù)設(shè)置,才能在某些方面對數(shù)據(jù)庫進行調(diào)優(yōu)。

前幾天剛接手一個MySQL數(shù)據(jù),操作系統(tǒng)為Ubuntu 16.04.5 LTS,  數(shù)據(jù)庫版本為5.7.23-0ubuntu0.16.04.1(APT方式安裝的MySQL)。這個操作系統(tǒng)下的MySQL的配置文件my.cnf很多地方都讓人有點不適應(yīng)(跟之前的MySQL環(huán)境有些出入,之前都是維護RHEL、CentOS等操作系統(tǒng)環(huán)境下的MySQL)。

遂研究總結(jié)了一下。具體如下所示:

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的參數(shù)文件為/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 其實是一個軟連接,指向參數(shù)文件/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是什么關(guān)系。那么我們先來看看參數(shù)文件/etc/mysql/my.cnf,從下面信息,可以看出“/etc/mysql/my.cnf”是全局配置,“~/.my.cnf”隱藏文件是個人用戶設(shè)置.

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參數(shù)文件下面沒有任何參數(shù)設(shè)置,只看到下面兩行設(shè)置,表示導(dǎo)入這兩個目錄里面的配置文件。

!includedir /etc/mysql/conf.d/    

#表示包含/etc/mysql/conf.d/這個路徑下面的配置文件,前提是必須以為.cnf為后綴

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

#表示包含/etc/mysql/mysql.conf.d/這個路徑下面的配置文件,前提是必須以為.cnf為后綴

其實MySQL的相關(guān)配置都位于mysqld.cnf(/etc/mysql/mysql.conf.d/mysqld.cnf)下面。使用相關(guān)參數(shù)測試了一下,確實都能生效。這種設(shè)置確實有點讓剛接觸的人有點不適應(yīng)。暫時先總結(jié)到此!

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

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。

相關(guān)文章

  • 關(guān)于MySQL?onlinedb數(shù)據(jù)庫的一些查詢語句大全

    關(guān)于MySQL?onlinedb數(shù)據(jù)庫的一些查詢語句大全

    這篇文章主要給大家介紹了關(guān)于MySQL?onlinedb數(shù)據(jù)庫的一些查詢語句,文中通過代碼實例介紹的非常詳細,對大家學(xué)習(xí)或者使用MySQL具有一定的參考價值,需要的朋友可以參考下
    2023-12-12
  • Windows安裝MySQL 5.7.18 解壓版的教程

    Windows安裝MySQL 5.7.18 解壓版的教程

    這篇文章主要為大家詳細介紹了Windows安裝MySQL 5.7.18 解壓版的詳細教程,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-07-07
  • 詳解MySQL中Order By排序和filesort排序的原理及實現(xiàn)

    詳解MySQL中Order By排序和filesort排序的原理及實現(xiàn)

    這篇文章主要為大家詳細介紹了MySQL的Order By排序的底層原理與filesort排序,以及排序優(yōu)化手段,文中的示例代碼講解詳細,感興趣的小編可以跟隨小編一起學(xué)習(xí)一下
    2022-08-08
  • MySQL數(shù)據(jù)庫三種常用存儲引擎特性對比

    MySQL數(shù)據(jù)庫三種常用存儲引擎特性對比

    MySQL中的數(shù)據(jù)用各種不同的技術(shù)存儲在文件(或內(nèi)存)中,這些技術(shù)中的每一種技術(shù)都使用不同的存儲機制,索引技巧,鎖定水平并且最終提供廣泛的不同功能和能力。在MySQL中將這些不同的技術(shù)及配套的相關(guān)功能稱為存儲引擎。
    2016-01-01
  • CentOs7.x安裝Mysql的詳細教程

    CentOs7.x安裝Mysql的詳細教程

    CentOS7的yum源中默認好像是沒有MySQL的。為了解決這個問題,我們要先下載mysql的repo源。下面通過本教程給大家詳細介紹CentOs7.x安裝Mysql的方法,一起看看吧
    2016-12-12
  • mysql 將字段time按天/月/年分組

    mysql 將字段time按天/月/年分組

    表中有一個字段time,格式為Unix時間戳,現(xiàn)需要按照該字段統(tǒng)計每天的記錄數(shù)并按天/月/年分組
    2014-07-07
  • 重置MySQL 8.0 Root密碼的簡便方法小結(jié)

    重置MySQL 8.0 Root密碼的簡便方法小結(jié)

    這篇文章主要給大家介紹了幾種輕松重置 MySQL 8.0 Root 密碼的簡便方法,文中通過代碼示例講解的非常詳細,對大家的學(xué)習(xí)或工作有一定的幫助,需要的朋友可以參考下
    2024-10-10
  • mysql主從服務(wù)器配置特殊問題

    mysql主從服務(wù)器配置特殊問題

    如果修改了主服務(wù)器的配置,記得刪除從服務(wù)器上的master.info文件。否則從服務(wù)器使用的還是老配置,可能會導(dǎo)致錯誤。
    2010-12-12
  • EXCEL數(shù)據(jù)上傳到SQL SERVER中的簡單實現(xiàn)方法

    EXCEL數(shù)據(jù)上傳到SQL SERVER中的簡單實現(xiàn)方法

    以下是對EXCEL數(shù)據(jù)上傳到SQL SERVER中的簡單實現(xiàn)方法進行了詳細的分析介紹,需要的朋友可以過來參考下
    2013-08-08
  • Mysql實現(xiàn)簡易版搜索引擎的示例代碼

    Mysql實現(xiàn)簡易版搜索引擎的示例代碼

    前段時間,因為項目需求,需要根據(jù)關(guān)鍵詞搜索聊天記錄,所以本文實現(xiàn)了Mysql實現(xiàn)簡易版搜索引擎,具有一定的參考價值,感興趣的可以了解一下
    2021-08-08

最新評論

景泰县| 翁源县| 正安县| 蒙阴县| 建瓯市| 黄大仙区| 渭源县| 青龙| 通州市| 什邡市| 平谷区| 朔州市| 鄂伦春自治旗| 观塘区| 海门市| 土默特左旗| 定州市| 红桥区| 乐东| 剑川县| 蒙山县| 钟祥市| 巫山县| 宜昌市| 双流县| 商水县| 常宁市| 五原县| 嘉义市| 治县。| 昌邑市| 桦南县| 华阴市| 彩票| 永靖县| 闽侯县| 安平县| 灵宝市| 东辽县| 百色市| 沁水县|