使用dump命令备份:
MySQL dump -u username -p tb_name >outfile
password:****
eg:
C:\Users\Administrator>mysqldump -uroot -p example0 pp>e:\pp.sql
Enter password: ****
打开两个cmd窗口可以方便查看mysql> use example0//Database changedmysql> show tables//+--------------------+| Tables_in_example0 |+--------------------+| course || k || n || po || pp || qq || sc || show_av || student || teacher || user_cost |+--------------------+
11 rows in set (0.00 sec)
mysql> drop table pp//Query OK, 0 rows affected (0.06 sec)mysql> show tables//(删除表,以便之后表的还原操作)+--------------------+| Tables_in_example0 |+--------------------+| course || k || n || po || qq || sc || show_av || student || teacher || user_cost |+--------------------+10 rows in set (0.00 sec)
还原:
mysql -u root -p tb_name<outfile
password:****
eg:
C:\Users\Administrator>mysql -u root -p example0<e:\pp.sql
Enter password: ****
mysql> show tables//+--------------------+| Tables_in_example0 |+--------------------+| course || k || n || po || pp || qq || sc || show_av || student || teacher || user_cost |+--------------------+11 rows in set (0.00 sec)