export mysql home_How to export mysql database to another computer?

问题

I created a database using Mysql Workbench. Now I want to export this database to my home PC.

How can I do this if the 2 PCs have no network connection?

回答1:

I use mysqldump to export the database. You can use something like

mysqldump -u [username] -p [database name] > backup.sql

to store it in a file. After that you can import into another database via

mysql -u [username] -p [database name] < backup.sql

回答2:

As edit was rejected posting it as an answer; hope it will be helpful.

Followed to the queries give by "Marc Hauptmann" -

Few quick-tips for generic issues that can be faced while performing DB dump and restore:-

As correctly mentioned above by "Marc" it is always advised not to provide db password in command line export [if you do so, it can be easily sniffed in history or reverse-search]

If you are transferring large dump file it is advised to compress it before transferring. [it should be uncompressed before restore]

While exporting if you want to export data with 'new database name' it can also be done. [It will require new Db to be created before using it in import]

Also if we are exporting data from production servers to make sure it doesn't impact performance, export from other servers with below additional option "-h [hostname]"

mysqldump -h [hostname] -u [username] -p [database name] > backup.sql

回答3:

Using gzip is pretty painless and really shrinks these files.

mysqldump -u [uname] -p[pass] [dbname] | gzip -9 > [backupfile.sql.gz]

gunzip < [backupfile.sql.gz] | mysql -u [uname] -p[pass] [dbname]

But man, it is 2014 - this stuff is also easy to do via a secure shell connection.

来源:https://stackoverflow.com/questions/18683119/how-to-export-mysql-database-to-another-computer

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值