Execute a SQL file via the MySQL command line in one line

Have a large script (like a DB dump) you want to execute from the command line in one line so you can just drop it in a batch/shell script and run with it?  Assuming MySql is on your system path, here’s the command…

mysql -u user -ppass < C:\temp\myscript.sql

Where "user" is the username, and "pass" is the password (note, there's no space or other delimiter between the "-p" and the password)

Like this? Consider joining my mailing list, or at least using my affiliate link when buying from Amazon 🙂

You or someone you know looking to buy or sell?

Leave a Reply