MySQL queries via bat file

Question:

MySQL is installed on the computer. I need to run it through the bat file and execute some sql queries that are in the query.sql file. I connect to MySQL with this line:

"C: \ Program Files \ MySQL \ MySQL Server 5.7 \ bin \ mysql.exe" -u root -proot Pause

Next, you need to enter queries from the query.sql file or, in extreme cases, in the batch file itself. How to do it?

Answer:

This one works

"C: \ Program Files \ MySQL \ MySQL Server 5.7 \ bin \ mysql.exe" mysql -uroot -proot <D: \ query.sql

Scroll to Top