mysql,命令导入\导出表结构或数量

于命令行下mysql的数量导出有个大好用命令mysqldump,它的参数有同一怪把,可以如此查看: 
mysqldump 

最常用的: 
mysqldump -uroot -pmysql databasefoo table1 table2 > foo.sql 

然便得拿数据库databasefoo的表table1,table2以sql形式导入foo.sql中,其中-uroot参数表示访问数据库的用户名是root,如果产生密码还需添加-p参数 

C:\Users\jack> mysqldump -uroot -pmysql sva_rec date_drv >
e:\date_drv.sql 

mysql的数码导入也是一定省事的,如: 
mysql -uroot databasefoo < foo.sql 

然就可用foo.sql的多少总体导入数据库databasefoo 

     1.导出一切数据库 

  mysqldump -u用户名 -p密码  数据库名 > 导出的文书名 
  C:\Users\jack> mysqldump -uroot -pmysql sva_rec  >
e:\sva_rec.sql 

  2.导出一个说明,包括表结构以及数量 

  mysqldump -u用户名 -p 密码  数据库名 表名> 导出底文书名 
  C:\Users\jack> mysqldump -uroot -pmysql sva_rec
date_rec_drv> e:\date_rec_drv.sql 

  3.导出一个数据库结构 
  C:\Users\jack> mysqldump -uroot -pmysql -d sva_rec >
e:\sva_rec.sql 

     4.导出一个发明,只有表结构 

  mysqldump -u用户名 -p 密码 -d数据库名  表名> 导出的文书名 
  C:\Users\jack> mysqldump -uroot -pmysql -d sva_rec
date_rec_drv> e:\date_rec_drv.sql 

  5.导入数据库 

  常用source 命令 
  进入mysql数据库控制台, 
  如mysql -u root -p 
  mysql>use 数据库 
  然后用source命令,后面参数为脚本文件(如这里以的.sql) 
  mysql>source d:wcnc_db.sql

==============

 

To export

If it’s an entire DB, then:

$ mysqldump -u [uname] -p[pass] db_name > db_backup.sql

If it’s all DBs, then:

$ mysqldump -u [uname] -p[pass] --all-databases > all_db_backup.sql

If it’s specific tables within a DB, then:

$ mysqldump -u [uname] -p[pass] db_name table1 table2 > table_backup.sql

You can even go as far as auto-compressing the output using gzip (if
your DB is very big):

$ mysqldump -u [uname] -p[pass] db_name | gzip > db_backup.sql.gz

If you want to do this remotely and you have the access to the server in
question, then the following would work (presuming the MySQL server is
on port 3306):

$ mysqldump -P 3306 -h [ip_address] -u [uname] -p[pass] db_name > db_backup.sql

To import

Type the following command to import sql data file:

$ mysql -u username -p -h localhost DATA-BASE-NAME < data.sql

In this example, import ‘data.sql’ file into ‘blog’ database
using Sathish as username:

$ mysql -u sat -p -h localhost blog < data.sql

If you have a dedicated database server, replace localhost hostname with
with actual server name or IP address as follows:

$ mysql -u username -p -h 202.54.1.10 databasename < data.sql

OR use hostname such as mysql.cyberciti.biz

$ mysql -u username -p -h mysql.cyberciti.biz database-name < data.sql

If you do not know the database name or database name is included in sql
dump you can try out something as follows:

$ mysql -u username -p -h 202.54.1.10 < data.sql

Refer: http://dev.mysql.com/doc/refman/5.6/en/mysqldump.html

If you want a GUI tool then you could probably
use SQLyog

 

网站地图xml地图