Create database
CREATE DATABASE `mydb`;
Create user
CREATE USER 'myuser' IDENTIFIED BY 'mypassword';
Grant permission to use server from localhost
GRANT USAGE ON *.* TO 'myuser'@localhost IDENTIFIED BY 'mypassword';
Grant permission to use server from other hosts
GRANT USAGE ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword';
Grant permission to use a database from localhost
GRANT ALL privileges ON `mydb`.* TO 'myuser'@localhost;
Grant permission to use a database from other hosts
GRANT ALL privileges ON `mydb`.* TO 'myuser'@'%';
Flush privileges
FLUSH PRIVILEGES;