Home » Create MySQL Database User

Create a MySQL user with password to access a MySQL database from a specific host to do things like adding, updating, deleting, and listing database records.

Requirements:

  • MySQL
  • MySQL User with Password
  • MySQL Host

How To Create A MySQL User From The Terminal.

Access the MySQL database first, and execute the code below once login to MySQL was successful.

CREATE USER 'USERNAME'@'HOST' IDENTIFIED BY 'PASSWORD';

Where.

  • USERNAME is the name of the user that will be created.
  • HOST is the server where the user will be allowed to log in from, usually localhost as default, but it can be an ip address.
  • PASSWORD is the password of the user.

Result.

Successful attempt will show message like below.

Query OK, 0 rows affected (0.135 sec)

Example of an unsuccessful try, ‘IDENTIFIED‘ was typed as ‘IDENTIFIE‘.

ERROR 1064 (42000): You have an error in your SQL syntax;
check the manual that corresponds to your MariaDB server version
for the right syntax to use near 'IDENTIFIE BY 'PASSWORD''
at line 1

Notes:

  • Including the PASSWORD value on the command line is a security risk, prompt MySQL to require the password.

References:


Posted

in

by

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *