Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql, dump, database restore

Tags:

I have dumped my database with the following command:

mysqldump -uuser -ppassword db_name > file 

then I completely removed my database:

drop database db_name; 

then I created a new database:

create database db_name; 

and then I tried to restore the db with the following command:

mysqldump -uuser -ppassword db_name < file 

The problem is that dump does not create tables and loads data in them and so the database remains empty however it does show a message like dump completed "date time"

What could be the reason for this?

like image 817
Furqan Asghar Avatar asked Feb 11 '11 19:02

Furqan Asghar


People also ask

How do I restore a database dump?

Use the mysql command to restore a database from the command line. In MySQL, you can use the mysql command to restore the database from a dump file. mysqldump is a command-line utility used to generate a MySQL logical database backup as a single . sql file with a set of SQL statements.


1 Answers

mysqldump is for dumping the database. You've created a new empty database, and then dumped that empty database. Use mysql instead to reload your dump

mysqldump db > dump.sql mysql drop/create mysql db < dump.sql 

would be the basic command sequence.

like image 58
Marc B Avatar answered Oct 28 '22 13:10

Marc B