Source: https://geekpeek.net/create-mysql-database/
mysql -u root -p
You should now be inside the MySQL repl. Do the following:
CREATE DATABASE `firstdb` /*!40100 DEFAULT CHARACTER SET utf8 */;
CREATE USER 'firstuser'@'localhost' IDENTIFIED BY 'HardPass';
GRANT ALL PRIVILEGES ON firstdb.* TO 'firstuser'@'localhost';
FLUSH PRIVILEGES;
Quit the MySQL repl by typing quit
.
You can test the permissions by starting the MySQL repl as the user you just created and entering show databases;
Run a SQL script on a database with:
mysql -u firstuser -p firstdb < dbdump.sql