Create New MySQL User and set Privileges

Introduction

This guide will show you how to make a new user and assign them all privileges to a specified database.

This is not a unique tutorial but is mainly intended as a quick reference for the author. Hope you find it useful though!

Steps

Create new database user along with their password. This will apply to all databases they access.

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';

Give user all privileges to a particular database

GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';

Necessary to apply the changes.

FLUSH PRIVILEGES;

References

https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql