天天看點

Mysql 獨享表空間

1.檢視目前的表空間:

[mysql@master ~]$ mysql -uroot -hlocalhost
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 55
Server version: 5.6.16-log Source distribution

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql>  show variables like 'innodb_data%';  
+-----------------------+------------------------+
| Variable_name         | Value                  |
+-----------------------+------------------------+
| innodb_data_file_path | ibdata1:12M:autoextend |
| innodb_data_home_dir  |                        |
+-----------------------+------------------------+
2 rows in set (0.07 sec)

[mysql@master data]$ ls -ltrh ibdata1 
-rw-rw----. 1 mysql mysql 460M Mar 14 13:47 ibdata1

2.
mysql> show variables like '%per_table%';    
+-----------------------+-------+
| Variable_name         | Value |
+-----------------------+-------+
| innodb_file_per_table | ON    |
+-----------------------+-------+
1 row in set (0.06 sec)

說明:OFF代表mysql是共享表空間,也就是所有庫的資料都存放在一個ibdate1檔案中


獨享表空間存儲方式使用“.ibd”檔案來存放資料,且每個表一個“.ibd”檔案,檔案存放在和MyISAM 資料相同的位置,由datadir确定。如果選用共享存儲表空間來存放資料,則會使用ibdata 檔案來

存放,所有表共同使用一個(或者多個,可自行配置)ibdata 檔案。ibdata 檔案可以通過innodb_data_home_dir 和innodb_data_file_path