datacharmer / test_db

A sample MySQL database with an integrated test suite, used to test your applications and database servers
4.06k stars 2.59k forks source link

Error loading source dump file. #5

Closed toufiqalamau closed 7 years ago

toufiqalamau commented 7 years ago

16:22:12 source load_departments.dump 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 load_departments.dump' at line 1 0.000 sec

Now I have this issue. Any guidance please? But of course, I am using the codes I have downloaded right from this source.

datacharmer commented 7 years ago

Please follow the instructions in README.md. If you do as it says, you will not find this problem.

kbanman commented 5 years ago

I'm having the same issue, after following the instructions exactly.

What I did:

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW ON *.* TO 'testuser'@'localhost' IDENTIFIED BY 'testpassword';
mysql -utestuser -p < employees.sql
Enter password: 
INFO
CREATING DATABASE STRUCTURE
INFO
storage engine: InnoDB
INFO
LOADING departments
ERROR 1064 (42000) at line 113: 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 load_departments.dump' at line 1

I'm using mysql 5.7.17

datacharmer commented 5 years ago

Can't reproduce the issue.

$ cd test_db
$ ~/sandboxes/msb_5_7_17/use -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.17 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql [localhost:5717] {root} ((none)) > GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW ON *.* TO 'testuser'@'localhost' IDENTIFIED BY 'testpassword';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql [localhost:5717] {root} ((none)) > ^DBye

$ ~/sandboxes/msb_5_7_17/use -u testuser -p < employees.sql
Enter password:
INFO
CREATING DATABASE STRUCTURE
INFO
storage engine: InnoDB
INFO
LOADING departments
INFO
LOADING employees
INFO
LOADING dept_emp
INFO
LOADING dept_manager
INFO
LOADING titles
INFO
LOADING salaries
data_load_time_diff
00:00:31

It is possible that your MySQL command is an alias or is a client from a different version.

Try this:

$ mysql --version
$ echo "select 1 as WORKING" > test.sql
$ echo "source test.sql" > test2.sql
$ mysql  < test2.sql
Foadsf commented 4 years ago

I hade the same problem on macOS, and solved it here, by running:

 mysql -u <user_name> -p -t < employees.sql

on the terminal.

westwoodmao commented 4 years ago

I'm a total noob in database. How do I run "mysql < employees.sql" in the shell?

Thanks!! I just want to create this test database that's all.

datacharmer commented 3 years ago

Sql 8.0 does not require source

This is false. See the manual

The solution is to comment those few lines with the "source" commands and run it.

This is WRONG. Don't do that. Of course the command will run, but it won't load the data!

The problem that you have is that the command is executed without changing directory to the place where the files are. Run it manually:

$ cd employees
$ mysql [options] < employees.sql
drngopal commented 3 years ago

I agree I was wrong. I am still unable to understand how do I change the directory manually. I am using mysql workbench on windows. Is there any way to configure it manually? I have deleted my comments to not misguide someone.

datacharmer commented 3 years ago

"Change the directory manually" means using the command line in a shell, as stated in my previous message. That's as far I can help you on Windows. For the use of MySQL Workbench, you should ask in another forum. I am a command line guy.

Studyhubsoftware commented 1 year ago

select prod_code as 'product code', count(*) as 'count', cast(avg (price) as int) as 'average' from product

22:49:56 select prod_code as 'product code', count(*) as 'count', cast(avg (price) as int) as 'average' from product 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 'int) as 'average' from product' at line 1 0.000 sec