0

I want to use my SQL'book_data2' file from the desktop E drive as a 'SOURCE'. But I am getting an error code 1064 in MySQL workbench. Could you help me for that issue? I am giving the code and action output below.

Code:

SOURCE E:\DataPractice\Practice\book_data2.sql;

Action Output:

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 'SOURCE E:\DataPractice\Practice\book_data2.sql' at line 1 0.000 sec

7
  • 1
    show the query code ... Commented Jan 10, 2021 at 17:54
  • Why do you have to stumble in this type of problem? ... You get an error code 1064? Google it. It shows you have syntax error. One step towards solving made. It tells you at line 1? Check the line 1 for any syntax error. Another step made ... Ah, it's another problem if you don't understand where the syntax error is. In this case, can you post some of the first lines of your sql file? Commented Jan 10, 2021 at 17:55
  • I have checked in line 1 but not getting any problem. I have already googled it as well but don't understand correctly that's why I have posted. The code is given below line 1. SHOW DATABASES; USE book_shop; SHOW TABLES; SOURCE E:\DataPractice\Practice\book_data2.sql; Commented Jan 10, 2021 at 17:58
  • Does this answer your question? How do you use MySQL's source command to import large files in windows Commented Jan 10, 2021 at 18:00
  • @Anik, well good. Then please share some lines from the sql file with us? Commented Jan 10, 2021 at 18:04

1 Answer 1

1

There are a number of commands that are supported by the mysql client (that is, the command-line client, not MySQL Workbench), but they are parsed in the client, not sent to the server as SQL statements. The MySQL Server does not recognize these commands.

It can be confusing, but remember both the client and the server may process commands. You just have to read the documentation to learn which commands are in the list of client-only commands:

https://dev.mysql.com/doc/refman/8.0/en/mysql-commands.html

(Except USE, which is recognized by both mysql client and server, just to make sure there's an exception to every rule!)

If you want to use MySQL Workbench to "source" an SQL file, in other words load a file, read the SQL commands in that file, and execute them, Workbench does support this action, but they call it Data Import/Restore. It's documented here: https://dev.mysql.com/doc/workbench/en/wb-admin-export-import-management.html

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

Comments

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.