Mysql : dump database along data

2019-02-03 02:04发布

I want to dump my database along the table schema and the table data also using the unix command line .

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.

标签: mysql sql dump
6条回答
【Aperson】
2楼-- · 2019-02-03 02:25

mysqldump offers plenty of options to build a proper backup from your database:

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:

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

查看更多
Juvenile、少年°
3楼-- · 2019-02-03 02:27

You just need to remove -d from your mysqldump command

查看更多
再贱就再见
4楼-- · 2019-02-03 02:33

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/

查看更多
成全新的幸福
5楼-- · 2019-02-03 02:42

To restore database from .sql dumpfile

mysql -u [yourusername] -p [password] [nameofthedatabase] < /pathtoyoursqldumpfile.sql

Use mysqldump to create backup from database.

mysqldump -u [yourusername] -p [password] [nameofthedatabase] > /pathtoyoursqldumpfile.sql

查看更多
贪生不怕死
6楼-- · 2019-02-03 02:47
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
查看更多
狗以群分
7楼-- · 2019-02-03 02:50

I think the command you would need will be mysqldump. Try the following:

mysqldump -u root -p -h localhost frontend < frontend.sql
查看更多
登录 后发表回答