restoring a MySQL database

I have created a file named ab.sql using the mysqldump utility of a database named library. It worked fine. Now i am trying to restore it using mysqlimport. My database already exists. But i want to override it. I am using the command

mysqlimport -uroot -p**** library D:/ab.sql

in the command line but it gives an error that says,

mysqlimport: Error: 1146, Table 'library.ab' doesn't exist, when using table: ab

desperately need help.


mysqlimport reads rows from a text file into a database. mysqldump outputs a file full of SQL statements, not simple rows. You can run those SQL statements using:

mysql -u root < D:/ab.sql

Depending on your mysqldump options, this may delete existing data in your database. If you're unsure, I'd grep for "drop" and "delete" to make sure it looks OK.

Marc B commented: Given your "not recognized" error, either it's not installed, or not in your path.

How to "Recognize" mysql

If you do have MySQL installed, say XAMPP 1.7.3 on Windows 7, installed to C:\xampp, you would need to open the Windows command line (cmd.exe) and change your path so that MySQL is included:

cd C:\xampp\mysql\bin

You would then add the command from froody's answer or some variant like:

C:\xampp\mysql\bin>mysql -u {DB_USER} -p {DB_NAME} < path/to/file/ab.sql

If you move the database file (i.e. the one you initially exported using mysqldump) to C:\xampp\mysql\bin before running the above command, you can leave off the path to the database file, leaving only:

C:\xampp\mysql\bin>mysql -u {DB_USER} -p {DB_NAME} < ab.sql

You will then be asked for the password of the database user. Then the command should execute. You should see something like this when it's finished:

Hope this helps and is accurate, with a little help from StackOverflow, this is how it worked for me. Good luck!

Need Your Help

Can a pointer (address) ever be negative?

c pointers return-value signed

I have a function that I would like to be able to return special values for failure and uninitialized (it returns a pointer on success).

mysqldump and restore with special characters. øæåØÆÅ

mysql mysqldump silverstripe

Locally I do this to dump and move a database, upgrading silverstripe 2.3 to 2.4: