1. 程式人生 > >Where does MySQL store database files

Where does MySQL store database files

如何知道MySql database 放在那裡,還有各個table 多大。

mysql 看系統變數指令:

SHOW VARIABLES WHERE Variable_Name LIKE "%dir";

Output (on Linux):

+---------------------------+----------------------------+
| Variable_name             | Value                      |
+---------------------------+----------------------------+
| basedir | /usr | | character_sets_dir | /usr/share/mysql/charsets/ | | datadir | /var/lib/mysql/ | | innodb_data_home_dir | | | innodb_log_group_home_dir | ./ | | lc_messages_dir
| /usr/share/mysql/ | | plugin_dir | /usr/lib/mysql/plugin/ | | slave_load_tmpdir | /tmp | | tmpdir | /tmp | +---------------------------+----------------------------+

Output (on macOS Sierra):

+---------------------------+-----------------------------------------------------------+
| Variable_name | Value | +---------------------------+-----------------------------------------------------------+ | basedir | /usr/local/mysql-5.7.17-macos10.12-x86_64/ | | character_sets_dir | /usr/local/mysql-5.7.17-macos10.12-x86_64/share/charsets/ | | datadir | /usr/local/mysql/data/ | | innodb_data_home_dir | | | innodb_log_group_home_dir | ./ | | innodb_tmpdir | | | lc_messages_dir | /usr/local/mysql-5.7.17-macos10.12-x86_64/share/ | | plugin_dir | /usr/local/mysql/lib/plugin/ | | slave_load_tmpdir | /var/folders/zz/zyxvpxvq6csfxvn_n000009800002_/T/ | | tmpdir | /var/folders/zz/zyxvpxvq6csfxvn_n000009800002_/T/

datadir 的目錄裡就可以看到 DB所有table.