Mysql:沿数据转储数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14022859/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Mysql : dump database along data
提问by masterofdestiny
I want to dump my database along the table schema and the table data also using the unix command line .
我想转储我的数据库沿表模式和表数据也使用 unix 命令行。
I used .
我用了 。
mysqldump -d -u root -p frontend > frontend.sql
But above command is dumping only schema not the data from the database .
但是上面的命令只转储模式而不是数据库中的数据。
Please help me out how can i dump the database along the data also.
请帮助我如何将数据库也与数据一起转储。
回答by Mari
backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
This will do,
这会做,
If your requirement is to dump data alone then go for this,
如果您的要求是单独转储数据,请执行此操作,
To export to file (data only)
导出到文件(仅限数据)
mysqldump -u [user] -p[pass] --no-create-db --no-create-info mydb > mydb.sql
回答by Raghvendra Parashar
backup: #
备份:#
mysqldump -u root -p[password] [database_name] > dumpfilename.sql
restore:#
恢复:#
mysql -u root -p[password] [database_name] < dumpfilename.sql
[ref:] http://www.thegeekstuff.com/2008/09/backup-and-restore-mysql-database-using-mysqldump/
[参考:] http://www.thegeekstuff.com/2008/09/backup-and-restore-mysql-database-using-mysqldump/
回答by Bennet Joseph
You just need to remove -d
from your mysqldump
command
你只需-d
要从你的mysqldump
命令中删除
回答by Nima Soroush
mysqldump offers plenty of options to build a proper backup from your database:
mysqldump 提供了许多选项来从您的数据库构建正确的备份:
mysqldump [options] db_name [tbl_name ...]
mysqldump [options] --databases db_name ...
mysqldump [options] --all-databases
Here you can find more detail about how to mysqldump:
在这里您可以找到有关如何 mysqldump 的更多详细信息:
回答by Rajesh M. Kanojia
To restore database from .sql dumpfile
从 .sql 转储文件恢复数据库
mysql -u [yourusername] -p [password] [nameofthedatabase] < /pathtoyoursqldumpfile.sql
mysql -u [您的用户名] -p [密码] [数据库名称]</pathtoyoursqldumpfile.sql
Use mysqldump to create backup from database.
使用 mysqldump 从数据库创建备份。
mysqldump -u [yourusername] -p [password] [nameofthedatabase] > /pathtoyoursqldumpfile.sql
mysqldump -u [您的用户名] -p [密码] [数据库名称] > /pathtoyoursqldumpfile.sql
回答by ktang
You're missing --no-data=False
你错过了 --no-data=False
e.g.
例如
mysqldump -d -u root frontend --no-data=False -p > frontend.sql
mysqldump -d -u 根前端 --no-data=False -p > frontend.sql
回答by Kevin Coyle
I think the command you would need will be mysqldump. Try the following:
我认为您需要的命令是 mysqldump。请尝试以下操作:
mysqldump -u root -p -h localhost frontend < frontend.sql