Skip to content

MySQL Recipes

Login Syntax

1
2
$ mysql -u <username> -p
Password: <enter password>

Create New User

1
mysql> CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

Grant User Privileges

1
2
3
4
5
6
7
> GRANT CREATE ON *.* TO 'username'@'localhost';
> GRANT INSERT ON *.* TO 'username'@'localhost';
> GRANT DELETE ON *.* TO 'username'@'localhost';
> GRANT DROP ON *.* TO 'username'@'localhost';
> GRANT SELECT ON *.* TO 'username'@'localhost';
> GRANT UPDATE ON *.* TO 'username'@'localhost';
> GRANT GRANT OPTION ON *.* TO 'username'@'localhost';