环境介绍:
MySQL版本:5.5.40
1.查看独立表空间是否开启
mysql> show variables like ‘%per_table%‘;
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| innodb_file_per_table | OFF |
+-----------------------+-------+
1 row in set (0.00 sec)
说明:OFF代表mysql是共享表空间
2.停止mysql服务器:
[[email protected] ~]#/etc/init.d/mysqld stop
3.修改my.cnf文件:
[mysqld]
innodb-file-per-table=1
4.启动mysql
[[email protected] ~]#/etc/init.d/mysqld start
5.验证功能是否开启
mysql> show variables like ‘%per_table%‘;
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| innodb_file_per_table | ON |
+-----------------------+-------+
1 row in set (0.00 sec)
总结:
1.如果线上服务器需要保存数据的,还要多加2步
a.使用mysqldump备份数据
b.使用mysql恢复对应数据
参考链接:http://blog.csdn.net/jacson_bai/article/details/44781033
2.删除旧文件时,既要删除ibdata*,也要删除相应log文件ib_logfile*,否则启动MySQL时,会提示异常缺少mysql.pid文件;