6

I have a file located at E:\Backup\sql\mybackup.sql

I'm logging into command line and I'm at the command prompt mysql>

How would I restore the database mydatabase?

I thought it was

mydatabase > "E:\Backup\sql\mybackup.sql"

but it keeps saying

unknown command at each \

4 Answers 4

8

Run it like:

mysql -h localhost -u root -p mydatabase < "E:/Backup/sql/mybackup.sql"
Sign up to request clarification or add additional context in comments.

Comments

3

In addition to the escaping issue, you have your redirection operator the wrong way around. Assuming you are using a shell which supports redirection of STDIN, you could try:

mysql mydatabase < E:\\Backup\\sql\\mybackup.sql

Comments

0

The command is

source "E:/Backup/sql/mybackup.sql"

First, specify the database (use dbname) - if it's not specified in the backup file

Comments

0

\ is the delimiter. Put \\ so you escape the \.

For windows users, use forward slashes for the path delimiters. You also don't need to enclose the path to the file in quotes. E.g., the following works:

mysql> source C:/Documents and Settings/My name here/My Documents/spike_loadingMySQLDB/createTables.sql;

As stated in the comment in https://dev.mysql.com/doc/refman/5.7/en/mysql-batch-commands.html

1 Comment

Do you need the quotes? Might give a try removing these :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.