Home > Database > Mysql Tutorial > body text

MySQL Innodb独立表空间的配置_MySQL

WBOY
Release: 2016-06-01 13:33:05
Original
1031 people have browsed it

bitsCN.com

MySQL Innodb独立表空间的配置

 

将数据库配置成独立表空间:

 

1.查看一下:

 

[sql] 

mysql> show variables like '%per_table%';    

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

| Variable_name         | Value |    

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

| innodb_file_per_table | OFF   |    

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

1 row in set (0.00 sec)    

说明:OFF代表mysql是共享表空间,也就是所有库的数据都存放在一个ibdate1文件中

 

rpm安装mysql的目录结构

 

数据库目录:/var/lib/mysql/

配置文件:/usr/share/mysql(mysql.server命令及配置文件)

相关命令:/usr/bin(mysqladmin、mysqldump等命令)(*mysql的一种安全启动方式:/usr/bin/mysqld_safe  --user=root &)

启动脚本:/etc/rc.d/init.d/

 

2.停掉mysql服务器:

 

[sql] 

以rpm方式安装的mysql  

[root@localhost ~]# /etc/rc.d/init.d/mysqld stop  

   

[sql] 

[root@localhost ~]#/etc/init.d/mysqld stop  

3.修改my.cnf文件:在my.cnf文件mysqld后面加上下面这句话:

 

因为是rpm安装,所以找不到,从mysql配置文件目录中随便复制个my-*.cnf文件到etc目录下,改成my.cnf

 

[sql] 

innodb-file-per-table=1  

4.启动mysql

 

[sql] 

[root@localhost ~]#service mysql start  

或  

[root@localhost ~]#/etc/init.d/mysqld start  

 

5.再查看一下

[sql] 

mysql> show variables like '%per_table%';    

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

| Variable_name         | Value |    

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

| innodb_file_per_table | ON   |    

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

1 row in set (0.00 sec)    

 

 

总结: mysql innodb的独立表空间和共享表空间,独立表空间是把每个表的数据和表文件放在一起。共享表空间是所有库的数据都放在ibdate1文件中,网上说这个文件你删除数据,不会收缩,也就是说如果你这个文件有40G,你删了表数据,这个文件还是40G,这就很恐怖了,所以我们换成独立表空间。还有就是虽然说独立,但个人觉得还真不是很彻底,我把那些文件复制到另一个库里面,只有表,没有数据,所以不彻底啊!

 

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!