MySQL : how to run an SQL script from the command line

December 5, 2008 – 5:24 pm

If you have an SQL script file you wish to run from the MySQL command line, you can use the source command at the MySQL command prompt as follows.

$ mysql --user=username --pass=password  database_name
mysql> source somescript.sql;
... script is run...
mysql> exit
$

Note that the path of the SQL script file is relative to where you started the MySQL command prompt from.

Simple!

Your Ad Here

Post a Comment