Mysql Add User Privileges

MySQL Add User Privilege

This is a quick MySQL snippet that allows me to add user privileges to a MySQL database. The script will create a user first, then it will grant various privileges to that user.

CREATE USER 'sqluser'@'%' IDENTIFIED BY 'sqlpassword';

GRANT USAGE ON *.* TO 'sqluser'@'%' IDENTIFIED BY 'sqlpassword'
WITH MAX_QUERIES_PER_HOUR 0
MAX_UPDATES_PER_HOUR 0
MAX_CONNECTIONS_PER_HOUR 0
MAX_USER_CONNECTIONS 0;

GRANT Create Temporary Tables, References, Insert, Alter, Lock Tables, Drop, Select, Update, Create, Index, Delete ON `db_name`.* TO `sqluser`@`%`;

Just change sqluser, sqlpassword, db_name and modify user permissions as required.

Marko