If you want to restore a mysql database from a sql file you have to issue this command:
[root@enix ~]#mysql -uroot -pxxx my-database < my-database-backup.sql
– where: my-database is your databse where you want to restore data;
– my-database-backup.sql is your sql backup file
– change root to your mysql user
– change xxx with your mysql password
And that’s it.
When dumping the database with mysqldump, use the option –no-create-db.
This will suspress the CREATE DATABASE statement in your dump file.
Then restore the database with
mysql -h <host> -u <user> -p <databasename> < dump.sql
In this way you can restore your data in whatever database you like (But that database has to exist!).
Leave a Reply