I am setting up an existing Magento site to run locally. The site uses MySQL, which I have installed and running on MacOS. I created a user doing the following:
> $ mysql -u root
CREATE USER 'username'@'localhost';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost';
SET PASSWORD FOR 'username'@'localhost' = 'Password1';
And then created the database
CREATE DATABASE dbname
When my site tries to connect it receives this error:
[2022-08-11 20:11:22] main.CRITICAL: SQLSTATE[HY000] [1045] Access denied for user ‘username’@’localhost’ (using password: YES) {“exception”:”[object] (Zend_Db_Adapter_Exception(code: 1045): SQLSTATE[HY000] [1045] Access denied for user ‘username’@’localhost’ (using password: YES) at /magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:144, PDOException(code: 1045): SQLSTATE[HY000] [1045] Access denied for user ‘username’@’localhost’ (using password: YES) at /magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:128)”} []
I can successfully log in using mysql -u username -p dbname
and entering the password. From there I’ve checked the granted permissions:
> SHOW GRANTS FOR 'username'@'localhost';
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for username@localhost |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `username`@`localhost` WITH GRANT OPTION |
| GRANT APPLICATION_PASSWORD_ADMIN,AUDIT_ABORT_EXEMPT,AUDIT_ADMIN,AUTHENTICATION_POLICY_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CLONE_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,FLUSH_OPTIMIZER_COSTS,FLUSH_STATUS,FLUSH_TABLES,FLUSH_USER_RESOURCES,GROUP_REPLICATION_ADMIN,GROUP_REPLICATION_STREAM,INNODB_REDO_LOG_ARCHIVE,INNODB_REDO_LOG_ENABLE,PASSWORDLESS_USER_ADMIN,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_APPLIER,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SHOW_ROUTINE,SYSTEM_USER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `username`@`localhost` WITH GRANT OPTION |
| GRANT ALL PRIVILEGES ON `username`.* TO `username`@`localhost` |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Yet when I try to access the site in the browser I get “Access Denied”.
Any suggestions?