0

The reference material says to use the source command like this:

mysql> source file_name

My .sql file is in a different directory, so I tried it a few ways:

Like this:

mysql> source c:\Users\Username\SQLdumps\sqlscript.sql;

and:

mysql> source 'c:\Users\Username\SQLdumps\sqlscript.sql';

and:

mysql> source "c:\Users\Username\SQLdumps\sqlscript.sql";

and

mysql> source \Users\Username\SQLdumps\sqlscript.sql;

and

mysql> source "\Users\Username\SQLdumps\sqlscript.sql";

In every case I get an error message that says to check the manual for syntax to use near source. What am I doing wrong?

jarlh
  • 42,561
  • 8
  • 45
  • 63
Michael T
  • 1,745
  • 5
  • 30
  • 42
  • Mofi you were right, the slashes were the wrong direction (I copy/pasted from windows explorer). But it needed to be without quotes. So the right way is: source c:/Users/Username/SQLdumps/sqlscript.sql; If you want to put that as an answer I will choose it. – Michael T Dec 12 '19 at 16:37
  • Does this answer your question? [How do I import an SQL file using the command line in MySQL?](https://stackoverflow.com/questions/17666249/how-do-i-import-an-sql-file-using-the-command-line-in-mysql) – nbk Dec 12 '19 at 16:42
  • Nbk no, I saw that one when I was looking for a solution but it doesn't address how to write the file name if it's in a different directory. See my comments above; Mofi solved it. – Michael T Dec 14 '19 at 02:06
  • I think it is a security precaution. iuse the mysql -uxyz -pvcd < sql . I don't see another option, if you want to import the file or you copy the executable instead of teh sql file – nbk Dec 14 '19 at 02:13
  • No, like I said I was able to make this work just fine, by switching the directions of the slashes. It was a simple fix. – Michael T Dec 15 '19 at 22:29

0 Answers0