Mysql : dump database along data

49,494

Solution 1

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

Solution 2

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/

Solution 3

You just need to remove -d from your mysqldump command

Solution 4

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

Share:
49,494
masterofdestiny
Author by

masterofdestiny

Updated on March 31, 2020

Comments

  • masterofdestiny
    masterofdestiny about 4 years

    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.

  • eggyal
    eggyal over 11 years
    Why is frontend.sql directed to stdin? Does mysqldump read from stdin?
  • masterofdestiny
    masterofdestiny over 11 years
    please check updated i tried that but it is dumping only schema
  • Mari
    Mari over 11 years
    @masterofdestiny can you try this and get back to me if you face any issues
  • FelikZ
    FelikZ over 10 years
    if your database engine is InnoDB, you will prefer to use --single-transaction option. Read more here.
  • Darkness Seeker
    Darkness Seeker almost 9 years
    the only bad thing with this answer is the direciton of the data redirection.. it should be ">", not "<".. > redirects the output from mysqldump into frontend.sql.. < READS the frontend.sql and redirects it to the stdin of mysqldump.. wich wil do nothing with it.