Newbie MySQL question about paths

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
robincanaday
Forum Newbie
Posts: 14
Joined: Thu Nov 20, 2008 12:25 am
Location: Portland Oregon USA

Newbie MySQL question about paths

Post by robincanaday »

I'm trying to use mysql cli in Windows to read a source sql file and run the queries therein.

I run this command:

Code: Select all

source c:\xampp\mysql\sql_files\common\tables.sql;
When I do this, it treats every backslash as a command starter... it says that \x and \m are not valid commands, then shows a status, then tries to clear the command, then does the notee command... How do I a build a path in mysql without it reading the backslashes as command starters? I tried enclosing the path in single quotes, and tried enclosing she slashes in single quotes and neither worked. Is there some other way to make the path string literal?

If I move and rename the file and run the command again:

Code: Select all

source ..\m\m.sql;
It will work after still telling me that \m is not a valid command twice.

I'm sure it's just such an elemental thing that Google failed me on this one...
Thanks for any help!
User avatar
it2051229
Forum Contributor
Posts: 312
Joined: Tue Dec 25, 2007 8:34 pm

Re: Newbie MySQL question about paths

Post by it2051229 »

in case of path use '\\'
something like
c:\\whatever\\whatever\\whatever.sql
robincanaday
Forum Newbie
Posts: 14
Joined: Thu Nov 20, 2008 12:25 am
Location: Portland Oregon USA

Re: Newbie MySQL question about paths

Post by robincanaday »

it2051229 wrote:in case of path use '\\'
something like
c:\\whatever\\whatever\\whatever.sql
Hmm, it runs correctly after giving me an 'Unknown Command \\' error for each double backslash.
It's better than calling other random commands :P.

Thanks :).
User avatar
it2051229
Forum Contributor
Posts: 312
Joined: Tue Dec 25, 2007 8:34 pm

Re: Newbie MySQL question about paths

Post by it2051229 »

well... shouldn't it be like
source "c:\\xampp\mysql\\sql_files\\common\\tables.sql";

if not then use the forward slash (/)
robincanaday
Forum Newbie
Posts: 14
Joined: Thu Nov 20, 2008 12:25 am
Location: Portland Oregon USA

Re: Newbie MySQL question about paths

Post by robincanaday »

Forward slash did it, thanks!
Odd that backslashes worked at all :P... it really confused everything.
Post Reply