Show all users and hosts
SELECT User, Host FROM mysql.user;
Show grants for logged in user
SHOW GRANTS;
Show all grants for a user
SHOW GRANTS FOR root;
Show all grants for a user and a host
SHOW GRANTS FOR root@'localhost';
Administrator with local access
CREATE USER 'milos'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'milos'@'localhost' WITH GRANT OPTION;
GRANT RELOAD, PROCESS ON *.* TO 'milos'@'localhost';
Administrator with access from anywhere
CREATE USER 'milos'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'milos'@'%' WITH GRANT OPTION;
GRANT RELOAD, PROCESS ON *.* TO 'milos'@'%';
Create user and add privileges to the database
CREATE USER 'custom'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER ON custom_database.* TO 'custom'@'localhost';