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?

yiwei
  • 4,022
  • 9
  • 36
  • 54

2 Answers2

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.

Community
  • 1
  • 1
j0hnstew
  • 709
  • 8
  • 25
  • 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? – yiwei Sep 23 '13 at 19:40
  • 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? – j0hnstew Sep 23 '13 at 19:42
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.

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181