To create a user and a database in MySQL, it doesn't take many commands. First of all, the database must be created.
CREATE DATABASE the_database_name;
Next, the user must be created. localhost describes here how the user can log in. In this case only locally. Alternatively, you can specify an external IP address here.
CREATE USER 'the_user_name'@'localhost' IDENTIFIED BY 'the_secure_password';
Last but not least, the user has to be granted rights to the previously created database. For the sake of simplicity, we will give the user all privileges.
GRANT ALL PRIVILEGES ON the_database_name.* TO 'the_user_name'@'localhost';