Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can not run a sql file windows command line using SOURCE command

hi i am using windows 7, xampp

. i am trying to run a sql file using CMD ut it gives me an error

ERROR:
Unknown command '\x'. 

this is what i am doing

enter image description here

this command is not working

mysql> SOURCE C:\xampp\htdocs\elephanti2\db\mas_gis_city_ip.sql;

*** one other problem with this works fine when i tried by go to phpmyadmin and import the file .

why this happening , i have no idea , please help ..................

like image 350
Kanishka Panamaldeniya Avatar asked Apr 23 '12 08:04

Kanishka Panamaldeniya


4 Answers

My original answer:

mysql> SOURCE C:\\xampp\\htdocs\\elephanti2\\db\\mas_gis_city_ip.sql;

You could also try executing the command like this:

mysql> SOURCE C:/xampp/htdocs/elephanti2/db/mas_gis_city_ip.sql;

(Source: a comment in the reference manual suggests using forward slashes on Windows machines)

like image 129
dwurf Avatar answered Oct 19 '22 05:10

dwurf


Try quoting your file name. Notice your command:

mysql> SOURCE C:\xampp\htdocs...

is probably being interpreted as:

mysql SOURCE C: \xampp \htdocs...

(see the \x there?)

If you quote the file name, I bet it'll work. (not sure if mysql requires ' or " for quoting filenames in this context, try both)

like image 37
Flimzy Avatar answered Oct 19 '22 06:10

Flimzy


Actually this worked. I think it is dwuff's previous answer.

mysql> SOURCE C:\\xampp\\htdocs\\elephanti2\\db\\mas_gis_city_ip.sql;
like image 2
Kanishka Panamaldeniya Avatar answered Oct 19 '22 06:10

Kanishka Panamaldeniya


I had the same problem recently trying to install FossTrak, and this was the syntax that worked on windows 10, with Mysql 5.7

\. C:/share/epcis-repository-0.5.0/epcis_schema.sql

using \source did not, and neither did \\, and by accident i removed the ; and it worked.

like image 1
StingyJack Avatar answered Oct 19 '22 07:10

StingyJack