MySQL 參數檔案及參數

來源:互聯網
上載者:User

標籤:資料庫   參數檔案   mysql   

MySQL的參數檔案為----my.cnf

  1. 如何確定資料庫讀取的哪一個,命令給出了答案

    [[email protected] home]# mysql --help |grep my.cnf
                          order of preference, my.cnf, $MYSQL_TCP_PORT,
    /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
    [[email protected] home]#

  2. 參數有的是為用戶端準備,有的是為伺服器準備

    [[email protected] home]# cat /etc/my.cnf | grep -v "^#"

    [client]

    port=3306

    [mysqld]
    datadir=/opt/mysql/data

    basedir = /usr/local/mysql
    socket=/usr/local/mysql/mysql.sock
    user=mysql
    character_set_server=utf8
    server_id = 12
    join_buffer_size = 128M
    sort_buffer_size = 2M
    pid-file=/opt/mysql/data/mysqld.pid
    [[email protected] home]#

  3. 什麼是參數?

    這個就好比是鍵跟值得關係 如read_buffer_size=12M read_buffer_size就是鍵 12M就是指

    分為兩類動態和靜態(唯讀),也可以分成是全域和局部的,動態可以修改但是只會在mysql server的整個生命週期中起作用,下次重啟之後會重新根據參數設定檔載入,所以要想永久生效還是修改設定檔,局部只對當前session有效,全域的對所有重新上來的會話有效,動態修改參數使用set [global] variables=key。

  4. 查看參數

    可以使用show variables like "variables_name" select @@session.variables_name select @@global.variables_name

    如查看read_buffer_size

    mysql> set read_buffer_size=524288;
    Query OK, 0 rows affected (0.07 sec)

    mysql> select @@session.read_buffer_size;
    +----------------------------+
    | @@session.read_buffer_size |
    +----------------------------+
    |                     524288 |
    +----------------------------+
    1 row in set (0.00 sec)

    mysql> select @@global.read_buffer_size;
    +---------------------------+
    | @@global.read_buffer_size |
    +---------------------------+
    |                    131072 |
    +---------------------------+
    1 row in set (0.00 sec)

    mysql> show variables like "read_buffer_size%";
    +------------------+--------+
    | Variable_name    | Value  |
    +------------------+--------+
    | read_buffer_size | 524288 |
    +------------------+--------+
    1 row in set (0.00 sec)

    可以看到同樣設定了read_buffer_size但是session和global卻不一樣 因為我設定的時候沒有加global

  5. 如果更改靜態參數會有什麼結果呢

    mysql> set global datadir=‘/opt‘;
    ERROR 1238 (HY000): Variable ‘datadir‘ is a read only variable
    mysql>



本文出自 “營運邦” 部落格,請務必保留此出處http://aklaus.blog.51cto.com/9724632/1632766

MySQL 參數檔案及參數

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.