Jun 17 2008

I’ve always used fancy tools like PhpMyAdmin to create users in mysql etc. as I don’t normally remember the syntax.

Here it is:

CREATE USER 'username'@'hostname'
     IDENTIFIED BY 'password';
GRANT USAGE ON * . * TO 'username'@'hostname'
     IDENTIFIED BY 'password'
     WITH
          MAX_QUERIES_PER_HOUR 0
          MAX_CONNECTIONS_PER_HOUR 0
          MAX_UPDATES_PER_HOUR 0
          MAX_USER_CONNECTIONS 0 ;

For each database you want the user to access, do:

GRANT ALL PRIVILEGES ON `databasename` . * TO 'username'@'hostname';

This basically means: create a user, with password “password”, don’t allow them to access anything except USAGE. Then, allow them to do anything they want in database “databasename”.

Leave a Reply