How to import a .sql file in MySQL?
Export:
mysqldump -u username –-password=your_password database_name > file.sql
Import:
mysql -u username –-password=your_password database_name < file.sql
You can also import an .sql file as an already connected user to the database manner :
mysql> use your_database_name;
mysql> source file.sql;
Another way to import dump files when source <filename>
doesn't work is to do the following:
Dump
~> mysqldump --user=<user> --password=<password> <db_name> > <export_file_name>.sql
Import
> mysql -u <user> -p <pass> <db_name>
mysql> USE <db_name>; (if you didn't already select)
mysql> \. ~/<export_file_name>.sql