MySQL随笔
mysql> show table status like 'user'\G
*************************** 1. row ***************************
Name: user
Engine: InnoDB
Version: 10
Row_format: Compact
Rows: 5
Avg_row_length: 3276
Data_length: 16384
Max_data_length: 0
Index_length: 0
Data_free: 0
Auto_increment: 6
Create_time: 2014-10-10 13:19:53
Update_time: NULL
Check_time: NULL
Collation: latin1_swedish_ci
Checksum: NULL
Create_options:
Comment:
1 row in set (0.00 sec)
mysql> check table user;
+----------------+-------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+----------------+-------+----------+----------+
| isso_test.user | check | status | OK |
+----------------+-------+----------+----------+
1 row in set (0.10 sec)
mysql> repair table user\G
*************************** 1. row ***************************
Table: test.user
Op: repair
Msg_type: note
Msg_text: The storage engine for the table doesn't support repair
1 row in set (0.27 sec)
如果数据库已经关闭,可以用myisamchk命令来检测和修复
可以使用myisampack对MyISAM对数据表进行压缩,可以减少I/O提高性能,后果是只读,不可修改表数据,读取表数据是解压也需要开销,这部分开销影响很小
mysql数据导出:
(1)导出整个数据库(包括数据库中的数据)
mysqldump -u username -p dbname > dbname.sql
(2)导出数据库结构(不含数据)
mysqldump -u username -p -d dbname > dbname.sql
(3)导出数据库中的某张数据表(包含数据)
mysqldump -u username -p dbname tablename > tablename.sql
(4)导出数据库中的某张数据表的表结构(不含数据)
mysqldump -u username -p -d dbname tablename > tablename.sql