Category Archives: MySQL

Setting up a MySQL User Account

Considering that this is a basic tutorial, it’s probably wise to show how to login to the MySQL client.

$ mysql -h localhost -p -u root

  • -h localhost: the hostname you’re connecting to
  • -p: suppresses the password prompt
  • -u root: user you’re logging in with

Setting up a MySQL user is as follows:

mysql> GRANT ALL ON mydatabase.* TO ‘monty’@'localhost’ IDENTIFIED BY ‘mtpass’;

  • The user will have access to the database named mydatabase
  • This creates a user named monty who’s locally accessing the database.
  • The password for the user will be mtpass.
  • It’s important to note that you’ll always have to grant privileges for the database even if the user account already exists. In that case you may want to omit IDENTIFIED BY ‘mtpass’.