
- To only create a new user on mysql:
CREATE USER username@localhost IDENTIFIED BY 'password';
- Create a new database:
CREATE DATABASE newdatabase;
- Create a new user and grant usage to a database:
grant all privileges on newdatabase.* TO 'username'@'localhost' identified by 'PASSWORD';
- Grant usage to an existing user:
GRANT ALL PRIVILEGES ON newdatabse.* TO 'username'@'localhost';
- Create a new remote user and grant usage to a database:
grant all privileges on newdatabase.* TO 'username'@'%' identified by 'PASSWORD';
Once everything is created, flush privileges in order to apply changes:
flush privileges;