MySQL new user SQL statements

A quick and dirty explanation to create a new MySQL datbase with a user

Create the user:

  • CREATE USER 'hibtest'@'localhost' IDENTIFIED BY '*******';
  • Set some permissions:

  • GRANT USAGE ON * . * TO 'hibtest'@'localhost' IDENTIFIED BY '*******' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0MAX_USER_CONNECTIONS 0 ;
  • Create the database:

  • CREATE DATABASE IF NOT EXISTS `hibtest` ;
  • Grant the privileges on the database:

  • GRANT ALL PRIVILEGES ON `hibtest` . * TO 'hibtest'@'localhost';