1

enter image description here

I tried so many ways to restore a sample database (with the command on top of the picture) but i failed every single time. i successfully restored with this command in past. but now i am facing this problem. And when i am putting "\" to specify path, there is an error saying '\s' is not a valid command. You can see it's showing "D:ample.sql" :(

asked Nov 21, 2016 at 9:34
3
  • change it for d:/sample.sql Commented Nov 21, 2016 at 9:43
  • and!!! what the mysql> at the begin of string? Commented Nov 21, 2016 at 9:43
  • mysqld is the server; you need a client to do the operation. Commented Nov 21, 2016 at 18:45

2 Answers 2

1

look like You try to run mysql(?d) from inside mysql console this command must be run from OS command line:

c:\Program Files\MySQL\bin>mysql -u root -p sample < d:/sample.sql

all from Windows command line

answered Nov 21, 2016 at 9:45
3
  • shouldn't he use path like this d:\sample.sql? Commented Nov 21, 2016 at 12:56
  • i tried both forward and backward slash but both failed.... and also from both mysql and windows command line.... still the same....... :( Commented Nov 21, 2016 at 16:57
  • Thanks a_vlad and Ahmed Abuhasna, both of you were right. :) the problem is solved. thanks to you guys :) Thanks a lot...... Commented Nov 21, 2016 at 17:14
1

since you are already logged in into MySQL then you need to inter the following command to read and execute text file

LOAD DATA INFILE 'd:/sample.sql' INTO TABLE mytable;

OR you can quit your MySQL session and execute the command

c:\mysql\bin\mysql -u root -p sample < d:\sample.sql

Notes: if you use the first method you may get the following error message:

ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

To fix it you need to add the following line into my.ini file and restart the service:

secure_file_priv=""
answered Nov 21, 2016 at 13:30
1
  • Thanks a_vlad and Ahmed Abuhasna, both of you were right. :) the problem is solved. thanks to you guys :) Thanks a lot........ Commented Nov 21, 2016 at 17:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.