1# if your database is not locally hosted
2mysql -u username -p -h dbhost dbname < filename.sql
1mysql -u username -p database_name < file.sql
2
3Note-1: It is better to use the full path of the SQL file file.sql.
4Note-2: Use -R and --triggers to keep the routines and triggers of original database.
5 They are not copied by default.
6Note-3 You may have to create the (empty) database from mysql if it
7 doesn't exist already and the exported SQL don't
8 contain CREATE DATABASE (exported with --no-create-db or -n option),
9 before you can import it.
1mysql> use db_name;
2
3mysql> SET autocommit=0 ; source the_sql_file.sql ; COMMIT ;
4