User Tools

Site Tools


info:mysql:user:create
Please note, that this is an old archived version of this site. Check out the new version at andunix.net!

MySQL: Create User

Create User

CREATE USER '{user}'@'%' IDENTIFIED BY '{passwd}';

Create User and Database

  • Usually, {user} == {db}
CREATE USER '{user}'@'%' IDENTIFIED BY '{passwd}';
 
GRANT USAGE ON * . * 
TO '{user}'@'%' 
IDENTIFIED BY '{passwd}' 
WITH 
  MAX_QUERIES_PER_HOUR 0 
  MAX_CONNECTIONS_PER_HOUR 0 
  MAX_UPDATES_PER_HOUR 0 
  MAX_USER_CONNECTIONS 0 ;
 
CREATE DATABASE IF NOT EXISTS `{db}`;
 
GRANT ALL PRIVILEGES ON `{db}` . *  TO '{user}'@'%';

Simpler Alternative:

CREATE DATABASE IF NOT EXISTS `dbname` DEFAULT CHARACTER SET = 'utf8';
GRANT ALL ON `dbname`.* TO 'dbuser'@'dbhost' IDENTIFIED BY 'dbpass';
info/mysql/user/create.txt · Last modified: 2016-01-25 11:49 by andunix