Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There are a few different ways to run multiple SQL files in batch in MySQL:

  1. Use the source command: Start by opening the MySQL command-line tool and logging in to your database. Then, use the "source" command to run each SQL file, like this:
mysql> source /path/to/file1.sql;
mysql> source /path/to/file2.sql;
  1. Use a script: You can also create a shell script that runs multiple SQL files at once. Here's an example:
#!/bin/bash

mysql -u your_username -p your_password your_database < /path/to/file1.sql
mysql -u your_username -p your_password your_database < /path/to/file2.sql

Make sure to replace "yourusername" and "yourpassword" with your MySQL login credentials, and "your_database" with the name of your database.

  1. Use a tool: There are also various third-party tools and plugins that can automate running multiple SQL files in batch. For example, MySQL Workbench allows you to create and save a script that runs multiple SQL files in order.