0

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.

3
  • Can you post the output of the following, censoring any data that you wouldn't want on the web? select User, Host, Password from mysql.user where User = "[THE USERNAME]" and select User, Db, Host from mysql.db where User = "[THE USERNAME]" Mar 10, 2017 at 21:32
  • The first query returned balsam % *E265936FB20A66C5498CCD3F2002B95CC0E4E561 and the second query returned balsam balsam %. The username and database name are the same. Mar 11, 2017 at 20:07
  • Please do not post the encrypted passwords.. I asked you to edit it. Mar 12, 2017 at 4:14

1 Answer 1

0

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 HASHED 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.

2
  • I ran the query for the passwords and I inserted the password for the user balsam, but the result was different passwords. Mar 13, 2017 at 18:03
  • After seeing the passwords are different, I ran an update statement changing the password of the user balsam to what I want it, and in my php application I am using balsam instead of me, but still I get the same error Mar 13, 2017 at 18:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .