Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Running SQL from File with MySQL

SQL mysql

  • Please log in to reply
2 replies to this topic

#1 LukeyJ

LukeyJ

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 94 posts

Posted 08 December 2011 - 11:27 AM

Hi all,

I'm trying to run a SQL file from the mysql command prompt. I connect to a DB and type:

source c:\etc...

without the dots. Unfortunately, I lose the prompt as if it is expecting more input. I type in ; to end it, but it won't stop reading. cntrl and C closes the window. Am I doing this correctly?

I have 3 SQL commands in the .sql file.

Any help would be brilliant.
  • 0

#2 Vaielab

Vaielab

    Programming God

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1382 posts
  • Location:Quebec City
  • Programming Language:Java, C++, C#, PHP, JavaScript, Visual Basic .NET, Transact-SQL, ActionScript

Posted 08 December 2011 - 11:33 AM

try adding quote "" around the file name

Did you select the database first (with use databaseName; )
And did you put the ; at the end of the first line?

If this is a long query, it may take some time.
  • 0

#3 LukeyJ

LukeyJ

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 94 posts

Posted 08 December 2011 - 12:04 PM

Thanks for the input.

I'm sorry to say it was a very silly mistake on my part. I saved it as a text file. So it didn't register the file name. Shame there was no meaningful warning. I'd just about given up on this, so thanks for pushing me just this little further to getting over the line! Blocker removed!
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download