1

I am facing an error while running command

bin/php magento setup:upgrade

It return the error shown below:

[Magento\Setup\Exception] Database user does not have enough privileges. Please make sure SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EVENT, TRIGGER privileges are granted to table 'magento_latest'.

6
  • Are you trying in localhost ? Jun 6, 2017 at 12:36
  • host => localhost in env.php
    – Mr.farhan
    Jun 6, 2017 at 12:39
  • Change it to 127.0.0.1 And then try again. Also make sure that your base url starts with 127.0.0.1 instead of localhost. Jun 6, 2017 at 12:40
  • Ok i have changed it to 127.0.0.1 But now getting these error. [Zend_Db_Adapter_Exception] SQLSTATE[HY000] [2002] Connection refused [PDOException] SQLSTATE[HY000] [2002] Connection refused
    – Mr.farhan
    Jun 6, 2017 at 12:44
  • Try using sudo. sudo php bin/magento setup:upgrade Jun 6, 2017 at 12:44

2 Answers 2

1

First of all, check your database username and password. Before you proceed to this step, you should have already set up the database in MySQL. You need to create a user and grant access privileges to that user.

1

Magento 2.1.x checks for the respective privileges to be given in \Magento\Setup\Validator\DbValidator::checkDatabasePrivileges. It looks for an exact match of the privileges in either information_schema.USER_PRIVILEGES or .SCHEMA_PRIVILEGES but neglects to combine both results, as MySQL would do when executing SQL statements.

Magento also checks for the exact current_user()(reference) to be matched. But sometimes privileges in MySQL are granted via wildcards e.g. '%'.

Magento only finds privileges if you grant to the connecting user explicitly: Try

GRANT ALL PRIVILEGES ON `mage\_db`.* TO 'mage_user'@'localhost';

instead of

[...] TO 'mage_user'@'%'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.