Here is the sample about how to create a MySQL user and grant access to the database. In this example I use
mysql command line tool.
First, let’s create a MySQL user:
CREATE USER 'user_name'@'%' IDENTIFIED BY 'user_password';
After creating a database user let’s grant access to the database for the created user, so that the user can have all rights on the database:
GRANT ALL PRIVILEGES ON mydatabase.* TO 'user_name'@'%';