5

I'm using MySQL Workbench and I have a series of .sql files stored from on my computer. I want to run these files from the query tab, but every time I use this command:

source '/Users/[username]/Documents/company/department.sql';

I get an Error 1064, which says "Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql> source '/Users/[username]/Documents/company/department.sql' at line 1 "

Can anyone tell me what I'm doing wrong?

1
  • Why don't you open department.sql from MySQL Workbench instead of sourcing? Commented Sep 24, 2013 at 1:19

2 Answers 2

0

In your MySQL console.

 mysql> use DB_NAME;
 mysql> source 'Users/[username]/Documents/company/department.sql';

Got the above from the answer here. Import SQL file into mysql

Also. From Console.

mysql -u root -p DB_NAME < Users/[username]/Documents/company/department.sql

I am not that familiar with MySQL WorkBench. I prefer using the console but these are the two methods to do what you want assuming that your .sql file contains proper sql.

Sign up to request clarification or add additional context in comments.

2 Comments

The issue is I'm not in the console I'm in the query tab (unless they're the same thing; I'm a newbie here). Do I type in the "mysql>" part?
no don't type in "mysql>". have you tried what I said to do above? If you have and it still does not work then are you sure the sql file is properly formatted?
0

The source command as well as the variant using the left angle char are solely features of the command line client. They make absolutely no sense in a GUI like MySQL Workbench. If you want to run a script open it in the SQL editor and click the button with the flash in the editor's toolbar to run it.

2 Comments

It makes perfect sense if you want to run a defined series of sql script files.
I agree. In order to automate script execution and history it would be essential to have this functionality.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.