Mysql – phpMyAdmin new user can’t connect to database

MySQLPHPphpmyadmin

I created a user in phpMyAdmin and I only want to allow query, insert and update operations, and in my php file I am trying to connect to the MySQL database but always get the error Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'me'@'localhost' (using password: YES), even though I entered the parameter to the mysqli constructor correctly. I read that I should tick the GRANT checkbox for the user however that didn't fix it. What am I missing here? Knowing that if I try it using root and no password I can connect successfully.

Best Answer

In a comment, I asked you to run the following queries to diagnose your issue:

select User, Host, Password
from mysql.user
where User = "[The Username]";

select User, Db, Host
from mysql.db
where User = "[The Username]"

Your answer suggests the user you created is balsam. This makes your issue very obvious -- you're attempting to connect to MySQL as user me, please use the correct username balsam.

Also, to make sure you're using the correct password you can run the following command:

select PASSWORD("[INSERT PASSWORD HERE]"), Password
from mysql.user
where user = 'balsam';

If running the previous commands yields the same value for both columns, you're using the correct password. If they aren't the same you'll need to either reset the password or delete the user grants and recreate the user account.

Make sure you're using the correct username, and not "me" as you posted in your question.