Software >> Services >> RDBMS >> MySQL >> How to create a new user and grant access to a DB

Example to

- create new user hfp
- grant this user access to all objects in database hfp
- the mysql server is assumed to require password for authentication

mysql --host='db_host_name' --user='root' --password

when prompted, enter root password

mysql> create database hfp;

mysq> CREATE USER 'hfp'@'db_host_name' IDENTIFIED BY 'hfp_password';

mysql> GRANT ALL PRIVILEGES ON hfp.* TO 'hfp'@'db_host_name'