To import sql file from command line in mysql type the following command:-
mysql -u root -p < /opt/projects/Test.sql
We have following options with import sql file from command line in mysql:-
- Better to use full path of the SQL file like: Test.sql.
- To Use -R and --triggers for keeping the routines and triggers of original database. They are not copied by default.
- You may have to create the (empty) database from mysql. If it doesn't exist already and exported SQL don't contain CREATE DATABASE (exported with --no-create-db or -n option), before you can import it.