Run sql file in database from terminal

I presume that it is MYSQL. To run it from Unix / Linux environment you must do this:

$ mysql -h "server-name" -u "your_username" -p "your_password" "database-name" < "filename.sql"

There is another way:

mysql --host=localhost --user=your_username --password=your_password  -e "filename.sql"

Leave a Comment