Try this to create new user in MySQL and give it access to database: 

CREATE USER 'username'@'hostname'; 
set password for 'username'@'localhost' = PASSWORD('password'); 

 

Try this to give it access to the database dbname : 

GRANT ALL PRIVILEGES ON dbname.* To 'username'@'hostname' IDENTIFIED BY 'password'; 

or with grant option :

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE ON `dbname`.* TO 'username'@'localhost' WITH GRANT OPTION; 

If you are running the code/site accessing MySQL on the same machine, hostname would be localhost. 

 

Now, the break down. 

GRANT - This is the command used to create users and grant rights to databases, tables, etc. 

ALL PRIVILEGES - This tells it the user will have all standard privileges. This does not include the privilege to use the GRANT command however. 

dbtest.* - This instructions MySQL to apply these rights for use in the entire dbtest database. You can replace the * with specific table names or store routines if you wish. 

TO 'user'@'hostname' - 'user' is the username of the user account you are creating. Note: You must have the single quotes in there. 

'hostname' tells MySQL what hosts the user can connect from. If you only want it from the same machine, use localhost 

IDENTIFIED BY 'password' - As you would have guessed, this sets the password for that user.