6

I am wanting to write and execute a single mysql .sql file that will execute multiple other .sql files. I am looking for something equivalent to Oracle's:

@script1.sql
@script2.sql
@script3.sql

Does MYSQL have a command?

2 Answers 2

11

From bash or any shell, you can run as follows

cat script*.sql | mysql -u root -pYOURPASSWORD  dbname

This would execute all for your sql files for 'dbname'

Cheers!!

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

Comments

4
source script1.sql;
source script2.sql;
...

1 Comment

I've actually tried that before, but no success. I am getting the error: 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 user.sql' at line 1. I have a build.sql file that I want to execute from within Eclipse that runs multiple files. Does the command you wrote have to be ran from a mysql prompt?

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.