MySQL 中的檔案!!

來源:互聯網
上載者:User

標籤:mysql   檔案   


mysql 中檔案


參數檔案:MySQL設定檔,儲存著mysql的配置資訊。檔案名稱my.cnf

預設情況,mysql執行個體會按照一定順序在指定的檔案讀取設定檔,使用者可以通過

mysql --help | grep  my.cnf 來尋找設定檔

也可以通過 whereis 命令來尋找my.cnf檔案

[[email protected] ~]# mysql  --help | grep  my.cnf

                      order of preference, my.cnf, $MYSQL_TCP_PORT,

/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf 

[[email protected] ~]# whereis my.cnf

my: /etc/my.cnf


錯誤記錄檔檔案:記錄對mysql的啟動,運行,關閉過程進行了記錄。

查看錯誤記錄檔

mysql> show global  variables  like  ‘log%error%‘;

+---------------+-------------------------------+

| Variable_name | Value                         |

+---------------+-------------------------------+

| log_error     | /home/data/192.168.57.132.err |

+---------------+-------------------------------+



慢查詢記錄檔:記錄耗時比較大的查詢或沒有使用到索引的查詢,來對資料庫進行最佳化。

與慢查詢相關的變數

log_output:滿查詢日誌和查詢日誌的輸出格式,預設情況下是file 

,可以將其更改table,更改為table之後,慢查詢sql記錄在mysql.slow_log中

mysql> show global  variables like  ‘log_output%‘;

+---------------+-------+

| Variable_name | Value |

+---------------+-------+

| log_output    | TABLE |

+---------------+-------+

1 row in set (0.00 sec)


mysql> set global  log_output=‘table‘ ;

Query OK, 0 rows affected (0.00 sec)


log_queries_not_using_indexes:沒有使用到索引的查詢是否記錄到慢查詢日誌,預設為off

log_slow_queries:是否啟用慢查詢日誌。預設為off

slow_query_log_file:慢查詢記錄檔的路徑

slow_query_log:是否開啟慢查詢日誌,該變數和log_slow_queries的功能相同

long_query_time:慢查詢閥值,預設為10s

如何利用慢查詢日誌進行效能調優:http://dwchaoyue.blog.51cto.com/2826417/1555269


查詢日誌:記錄著所有對mysql資料庫請求的資訊,無論這些請求得到了正確的執行。輸出格式

同樣是由log_output控制。

general_log:是否開啟查詢日誌 

general_log_file:查詢記錄檔的路徑

mysql> show global variables like  ‘general%‘;

+------------------+--------------------+

| Variable_name    | Value              |

+------------------+--------------------+

| general_log      | ON                 |

| general_log_file | /home/data/192.log |

+------------------+--------------------+


通訊端檔案:Unix系統本地串連mysql的一種方式

mysql> show global  variables  like  ‘%sock%‘;

+---------------+-----------------------+

| Variable_name | Value                 |

+---------------+-----------------------+

| socket        | /home/data/mysql.sock |

+---------------+-----------------------+

1 row in set (0.00 sec)


pid檔案:用來儲存mysql執行個體的進程Id,路徑可以由pid_file控制

mysql> show global  variables  like  ‘%pid%‘;

+---------------+-------------------------------+

| Variable_name | Value                         |

+---------------+-------------------------------+

| pid_file      | /home/data/192.168.57.132.pid |

+---------------+-------------------------------+


表結構定義檔案:儲存表的結構,尾碼為.frm,不管表使用的是什麼儲存引擎,都會有一個.frm檔案與表結構對應。

擴充:對於MYISAM儲存引擎而言還包括.myd(資料)  .myi(索引)檔案

[[email protected] csevent]# ll

total 988

-rw-rw----. 1 mysql mysql  8790 Sep 14 03:57 cm_announce.frm

-rw-rw----. 1 mysql mysql  9012 Sep 14 03:57 cm_block_game_accounts.frm

-rw-rw----. 1 mysql mysql  8640 Sep 14 03:57 cm_bug_types.frm

-rw-rw----. 1 mysql mysql  8714 Sep 14 03:57 cm_c2corder_locked.frm

-rw-rw----. 1 mysql mysql  8754 Sep 14 03:57 cm_client_system.frm


資料表空間檔案:innodb 儲存引擎將資料存放區在資料表空間檔案中.所有基於InnoDB儲存引擎的資料都會儲存在資料表空間中.

與資料表空間相關的部分變數:

mysql> show global  variables  like  ‘innodb_data_%‘;

+-----------------------+------------------------+

| Variable_name         | Value                  |

+-----------------------+------------------------+

| innodb_data_file_path | ibdata1:10M:autoextend |

| innodb_data_home_dir  |                        |

+-----------------------+------------------------+


重做記錄檔:交易記錄檔,是InnoDB儲存引擎專屬的。

與重做日誌相關的部分變數

mysql> show global  variables  like  ‘innodb_log_%‘;

+---------------------------+---------+

| Variable_name             | Value   |

+---------------------------+---------+

| innodb_log_buffer_size    | 1048576 |

| innodb_log_file_size      | 5242880 |

| innodb_log_files_in_group | 2       |

| innodb_log_group_home_dir | ./      |

+---------------------------+---------+


二進位日誌:記錄了對mysql資料庫執行的所有操作。

與二進位日誌相關的部分變數

mysql> show global  variables  like  ‘binlog%‘;

+-----------------------------------------+-----------+

| Variable_name                           | Value     |

+-----------------------------------------+-----------+

| binlog_cache_size                       | 32768     |

| binlog_direct_non_transactional_updates | OFF       |

| binlog_format                           | STATEMENT |

+-----------------------------------------+-----------+


這裡主要對與MySQL相關檔案進行簡單的概述,其中資料表空間檔案,重做交易記錄檔,二進位檔案

是最重要的檔案,以後會這幾個檔案進行詳細的概述。



本文出自 “SQLServer MySQL” 部落格,請務必保留此出處http://dwchaoyue.blog.51cto.com/2826417/1572705

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.