简体   繁体   中英

Run multiple sql files in mysql batch

to run a single file you can run in mysql

.\\ filename

or you outside of mysql you can run

mysql < filename

I have a directory of sql files so I'm trying to run them all at once by using a wildcard

*.sql

but it doesn't work.

Any ideas?

假设你正在使用bash:

cat *.sql | mysql

对于Windows:

FOR %%A IN ("*.sql") DO "D:\mysql\Install\MySQL Server 5.5\bin\mysql" --user=scooby --password=pwd123 databasename < %%A >output.tab
for %S in (*.sql) do mysql -u user_name database_name < %S

要么

mysql -u user_name -p password database_name < file.sql

庆典:

for sql_file in `ls /path/to/directory/*.sql`; do mysql -uUSER -pPASSWORD DATABASE < $sql_file ; done

庆典:

mysql < <(cat *.sql)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM