MySQL导出导入命令的用例

导出一个数据库结构

  格式:mysqldump -u 用户名 -p -d –add-drop-table 数据库 > 导出的文件名

  说明:-d 选项表示没有数据    

  –add-drop-table 选项说明在每个create语句之前增加一个drop table

  举例:表结构与上面的相同

  C:MySQLMySQL Server 5.0bin>mysqldump -u root -p -d –add-drop-table testdb > testdbstruct.sql

  Enter password:

 

导入数据库

  格式:常用source 命令

  进入mysql数据库控制台:

  C:MySQLMySQL Server 5.0bin> -u root -p

  Enter password:

  Welcome to the MySQL monitor.  Commands end with ; or g.

  Your MySQL connection id is 10 to server version: 5.0.7-beta-nt

  Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the buffer.

  mysql> use testdb;

  Database changed

  mysql> source testdb.sql;

  Query OK, 0 rows affected (0.05 sec)

testdb.sql放在C:MySQLMySQL Server 5.0bin目录下,如果不在这个目录下则要指定路径

原创文章,转载请注明: 转载自PT Ubuntu Blog

本文链接地址: http://www.ptubuntu.com/2009/04/2278.html

Share

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Verify Code   If you cannot see the CheckCode image,please refresh the page again!