Notes

Import a MySQL database

# Log in
mysql -u root -p
# Create a new user
mysql> create user 'username'@'localhost' identified by 'userpassword';
# Create a new database
mysql> create database 'databasename';
# Let 'username' use the new database
mysql> grant usage on *.* to 'username'@'localhost' identified by 'userpassword';
mysql> grant all priviliges on databasename.* to 'username'@'localhost';
# Import an existing database
mysql -u username -puserpassword -h localhost databasename < databasetoimport.sql

For database names with hyphens wrap the name in backticks, e.g.:

mysql> create database `database-with-hyphen-name`;