How To Create a New User and Grant Permissions in MySQL

I always forget the MySQL create database with UTF8 character set syntax, so here it is:

CREATE DATABASE mydb CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL ON mydb.* TO username@localhost IDENTIFIED BY ‘password’;
FLUSH PRIVILEGES;

Alternatively, you can use ‘CREATE SCHEMA’ instead of ‘CREATE DATABASE’:

CREATE SCHEMA mydb CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL ON mydb.* TO username@localhost IDENTIFIED BY ‘password’;
FLUSH PRIVILEGES;

I hope this helps someone else too!