Home / Databases / MySQL / How can I run sql commands from a file or import tables from the mysqldump?
How can I run sql commands from a file or import tables from the mysqldump?
Last updated: 06/27/2009
There are two options for running sql commands from a file:
1. All command line:
mysql -u [username] -h [hostname] -p [database] < [filename.sql]
2. From the mysql command line:
mysql> source [filename.sql]
The second is helpful when you want to execute a few commands prior to loading in the file, such as selecting the database, setting some mysql options, etc.