views:

69

answers:

5

I have a .sql file generated by MysqlDump. How can i restore it via command prompt

+2  A: 
$ mysql database < myfile.sql

OR

$ mysql database
mysql> source myfile.sql
scompt.com
A: 

The syntax is:

mysql database_name < file.sql

See: Using mysql in Batch Mode

Seth
I am using normal window cmd..And i tried this. But no results and no error..... C:\MySQL\MySQL Server 5.0\bin>mysql -uroot -ppassword mysql > source d:\admindb\ aar12.sql
Anuya
The syntax is as I wrote above. What you've done there is redirect the output of the `mysql` command a file called `source` in your working directory. (Your redirection arrow is pointing the wrong way, should be `<`, and you have too many parameters).
Seth
A: 
mysql -uusername -ppassword databasename < file.sql

or if the file is gzipped (like my backups mostly are) then something like this:

gunzip file.sql.gz | mysql -uusername -ppassword databasename
Nathan Reed
A: 

From within MySQL command prompt, type

SOURCE file.sql
dare2be
A: 
  1. get to bin directory of mysql using command prompt
  2. log in to mysql
  3. run source command with file parameter

Example :

cd C:\mysql\bin
mysql -u root -p
mysql > source c:\myfile.sql
Xorty
You don't have to be in the MySQL bin directory if your system is sane, and by sane, I mean has the MySQL bin directory in the PATH.
icktoofay
I am using normal window cmd..And i tried this. But no results and no error.....C:\MySQL\MySQL Server 5.0\bin>mysql -uroot -ppassword mysql > source d:\admindb\aar12.sql
Anuya
well in third step, don't write "mysql >" :)
Xorty
I am not getting any errors. But there is no update when i see in my query browser. The script works fine when executing manually in query browser. Tried this in cmd : C:\MySQL\MySQL Server 5.0\bin>mysql -uroot -ppassword source d:\admindb\AAR12.sql
Anuya