mysqldump doesn't restore database. why not?

You have to use the mysql client to reload

mysql -u root -p -Ddatabasename < /home/databasename_bkup.sql  

Another way to reload would be

mysql -u root -p -Ddatabasename

then from the MySQL prompt, do this

mysql> source /home/databasename_bkup.sql  

If you would like the mysqldump to drop and recreate the database for you, create the dump like this:

mysqldump -u root -p --add-drop-database -B databasename > /home/databasename_bkup.sql  

Then, running the script

mysql -u root -p < /home/databasename_bkup.sql  

does the DROP DATABASE command for you.


Basically there is a basic difference between the command to take backup and restore a mysql database on linux servers

To take a backup we have to use a command mysqldump like this on the command prompt

#mysqldump -u [username] -p[password] [databasename] > [backupfilename] 

but when you want to restore the same backup on the server, you should write a command like this

#mysql -u [username] -p[password] [databasename] < [backupfilename] 

most of the time people use mysqldump command to restore the database tables thus mysql is not able to create tables or insert rows


dont use "mysqldump" while restoring backup. Use "mysql". mysqldump is for taking backup, not for restoring.