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" :(
2 Answers 2
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
-
shouldn't he use path like this
d:\sample.sql
?Ahmad Abuhasna– Ahmad Abuhasna2016年11月21日 12:56:21 +00:00Commented 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....... :(Itachi– Itachi2016年11月21日 16:57:10 +00:00Commented 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......Itachi– Itachi2016年11月21日 17:14:20 +00:00Commented Nov 21, 2016 at 17:14
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=""
-
Thanks a_vlad and Ahmed Abuhasna, both of you were right. :) the problem is solved. thanks to you guys :) Thanks a lot........Itachi– Itachi2016年11月21日 17:13:45 +00:00Commented Nov 21, 2016 at 17:13
mysqld
is the server; you need a client to do the operation.