Restoring a MySQL table back to the database

Taking backup

mysqldump -u -p mydatabase table1 > database_dump.sql

restoring from backup flie need not include table name

mysql -u -p mydatabase < database_dump.sql

Ah, I think I see the problem here.

Your backup script looks fine. tbl_name works correctly as the optional 2nd argument.

To restore, you should simply run

mysql -uroot -p DatabaseName < path\TableName.sql

Running man mysql would have shown you the correct arguments and options

mysql [options] db_name

As your backup script only contains one table, only that table will be restored into your database.

Tags:

Mysql