从命令行下载MySQL转储 [英] Downloading MySQL dump from command line
问题描述
我离开了Linode,因为我没有必要的Linux系统管理技能;在我完成转换到更加noob友好的服务之前,我需要下载MySQL数据库的内容。
I am moving away from Linode because I don't have the Linux sysadmin skills necessary; before I complete the transition to a more noob-friendly service, I need to download the contents of a MySQL database. Is there a way I can do this from the command line?
推荐答案
你可以使用 mysqldump 命令行函数。
You can accomplish this using the mysqldump command-line function.
例如:
如果是整个数据库,则
$ mysqldump -u [uname] -p[pass] db_name > db_backup.sql
如果是所有DB,则:
$ mysqldump -u [uname] -p[pass] --all-databases > all_db_backup.sql
如果是DB中的特定表,则:
If it's specific tables within a DB, then:
$ mysqldump -u [uname] -p[pass] db_name table1 table2 > table_backup.sql
你甚至可以使用gzip自动压缩输出非常大):
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
如果您要远程 (假定MySQL服务器在端口3306上):
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
应该删除 .sql
文件在您从<文件夹>运行命令行的文件夹中。
It should drop the .sql
file in the folder you run the command-line from.
这篇关于从命令行下载MySQL转储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!