Import a mysql database from terminal

mysql -u username -ppassword databasename < filename.sql

Example
Username: daniel
Password: 123Headadmin
Database name: my_new_db
Database file name: my_old_db.sql

mysql -u daniel -p123Headadmin my_new_db < my_old_db.sql

Rename a database in phpMyAdmin

I wanted to change a MySQL database name via phpMyAdmin. This is how I did it:

1. Login to phpMyAdmin.
2. Select the database you want to rename.
3. Click on operations tab.
4. In the “rename database to” section, specifiy the new name of the database.
5. You will get a question saying “CREATE DATABASE olddatabasename / DROP DATABASE newdatabasename”. Click ok.
6. Next you will be asked to reload the database. Click yes.

What happens is that you areĀ  creating a new database with a new name, dumping all tables of the old database into the new database and droping the old database. So remember that you will have to check your privileges becuase the old privileges from the old database will not be included.

If you are running a WordPress website you need to modify wp-config.php to start using the new database name.