欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

mysql表的备份还原操作教程

程序员文章站 2022-11-28 13:10:33
使用dump命令备份: mysql dump -u username -p tb_name >outfile password:**** eg: c:\users\administrator&...

使用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 changed

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)

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

password:****

eg:

c:\users\administrator>mysql -u root -p example0

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)