How can I import a database with MySQL from terminal?

Prompt for password:

 mysql -u username -p databasename < filename.sql  

Enter password directly (not secure):

 mysql -u username -pPlainPassword databasename filename.sql 

Example:

mysql -u root -p wp_users < wp_users.sql

mysql -u root -pPassword123 wp_users --default-character-set=utf8 < wp_users.sql

See also:
4.5.1.5. Executing SQL Statements from a Text File

You may also like...