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

21,417

Solution 1

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)

Solution 2

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

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

Solution 3

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)

Solution 4

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.

Share:
21,417
Kanishka Panamaldeniya
Author by

Kanishka Panamaldeniya

LinkedIn

Updated on July 15, 2022

Comments

  • Kanishka Panamaldeniya
    Kanishka Panamaldeniya almost 2 years

    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 ..................

  • Simon East
    Simon East about 7 years
    Yep, and remember not to include quotes around the path, which also tripped me up.
  • Frank Forte
    Frank Forte about 5 years
    Strange enough, I had to remove the semi-colon to get it working.