Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

restoring with mysqldump, but where is the data?

Ok, so I'm in need to restore a table and I do:

mysqldump --opt database table_name < table_name.sql 

I hit enter and Done! Well, not really, when I go to see if there is anything on the table it show 0 records.

I have look into the table_name.sql and I see two records.

What am I doing wrong?

like image 220
Ole Media Avatar asked Apr 16 '10 21:04

Ole Media


2 Answers

mysqldump is the wrong command for restoring from a backup.

You need to run mysql, as in, the mysql client. It's generally something like this:

mysql -u username -p database_name < sqlfile.sql

That will use your file as input to the mysql client, which subsequently executes the SQL.

like image 57
zombat Avatar answered Oct 03 '22 01:10

zombat


mysqldump just exports the data to an SQL script. You can restore with this:

mysql db < file.sql
like image 32
Osama Al-Maadeed Avatar answered Oct 03 '22 02:10

Osama Al-Maadeed