MySQL: Create User

Create User

CREATE USER '{user}'@'%' IDENTIFIED BY '{passwd}';

Create User and Database

CREATE USER '{user}'@'%' IDENTIFIED BY '{passwd}';
 
GRANT USAGE ON * . * 
TO '{user}'@'%' 
IDENTIFIED BY '{passwd}' 
WITH 
  MAX_QUERIES_PER_HOUR 0 
  MAX_CONNECTIONS_PER_HOUR 0 
  MAX_UPDATES_PER_HOUR 0 
  MAX_USER_CONNECTIONS 0 ;
 
CREATE DATABASE IF NOT EXISTS `{db}`;
 
GRANT ALL PRIVILEGES ON `{db}` . *  TO '{user}'@'%';

Simpler Alternative:

CREATE DATABASE IF NOT EXISTS `dbname` DEFAULT CHARACTER SET = 'utf8';
GRANT ALL ON `dbname`.* TO 'dbuser'@'dbhost' IDENTIFIED BY 'dbpass';