MySQL / MariaDB - Create Database User with Password

Raymond Tang Raymond Tang 0 482 0.29 index 12/28/2020

This code snippet shows you how to create a database user with password in MySQL or MariaDB.

Code snippet

The following code snippet creates a user named 'hive' with password ('hive') that never expires.

CREATE USER 'hive'@'localhost' IDENTIFIED BY 'hive' password expire never;

Grant permissions

The following SQL statement grants all permission to user 'hive':

GRANT ALL ON *.* TO 'hive'@'localhost';
mysql

Join the Discussion

View or add your thoughts below

Comments