I've been trying to install Magento for weeks, and I keep running into this error when I try to add a database. The problem is not the database credentials. I've tried multiple databases and users, with and without passwords, and get the same result each time.
I was finally able to install Magento 2 after uninstalling and reinstalling MAMP Pro a couple of days ago. Then, I updated my PC, and the site was no longer working. Instead there was an error message telling me to view the details in the exceptions log. This is roughly how the first line of that log file said:
main.CRITICAL: exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user
I deleted those site files and decided to try installing Magento again, and sure enough, I got the same error message when trying to add a database. I'm at my wit's end. I don't know what else to try, and google hasn't been much help since the problem isn't my mysql credentials. I'm not reinstalling MAMP Pro every time I restart my computer.
If it helps, here's my environment setup:
Windows 10
MAMP Pro 4.1
PHP: 7.2.10
Solved! Go to Solution.
It looks like I had 2 versions of MySQL installed on my computer: MySQL by itself and what's included with MAMP Pro, and the standalone version was occupying port 3306. So, even though the databases were set up correctly, it wasn't working because Magento was looking for the databases in the other MySQL program.
I uninstalled the other MySQL program and made sure the MAMP Pro version was using port 3306 (it had switched to 3307 because the other port was occupied). After that, I was able to install Magento 2 with no issues.
Your user don't have all the permissions. So please grant all permissions
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'username'@'localhost';
FLUSH PRIVILEGES;
Once you have all permission. You will not face such problems.
I've tried that already. I've also tried the root user, which has global permissions. I still get the error same message.
It looks like I had 2 versions of MySQL installed on my computer: MySQL by itself and what's included with MAMP Pro, and the standalone version was occupying port 3306. So, even though the databases were set up correctly, it wasn't working because Magento was looking for the databases in the other MySQL program.
I uninstalled the other MySQL program and made sure the MAMP Pro version was using port 3306 (it had switched to 3307 because the other port was occupied). After that, I was able to install Magento 2 with no issues.
Hiya, I think I may have a similar issue to you. What was the other MySql program that was installed?
That error message usually means that either the password we are using doesn't match what MySQL thinks the password should be for the user we're connecting as, or a matching MySQL user doesn't exist (hasn't been created). In MySQL, a user is identified by both a username ("test2") and a host ("localhost").