1

drush sql-connect produces valid, working MySQL credentials:

mysql --user=drupaluser --password= --database=core_20161101 --host=127.0.0.1 --port=33067

So does drush status:

Database driver : mysql
Database hostname : 127.0.0.1
Database port : 33067
Database username : drupaluser
Database name : core_20161101

However drush -d uinf admin and anything else that needs to read the database fails with:

[...] sql-query: SELECT 1; [0.35 sec, 4.88 MB]
[notice] Executing: mysql --defaults-extra-file=/private/tmp/drush_dZeMQb --database=core_20161101 --host=127.0.0.1 --port=33067 --silent < /private/tmp/drush_Tu2o2g ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) Bootstrap to phase 1. [0.37 sec, 4.88 MB]
[bootstrap] Bootstrap to phase 6. [0.54 sec, 6.68 MB]
[bootstrap] Bootstrap to phase 5. [0.54 sec, 6.68 MB]
[bootstrap] Command user-information needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command. [0.54 sec, 6.68 MB]
[error] The drush command 'uinf admin' could not be executed. [0.54 sec, 6.68 MB]
[error] Drush was not able to start (bootstrap) the Drupal database. [...]

Note the username is wrong, root@localhost, not [email protected].

Any ideas why it would be switching to the wrong username?

Versions:
Acquia Dev Desktop 2 (built Sep 5 2016)
PHP 5.5.33 (as set by Dev Desktop)
Drush 8.0.5
Mac OS 10.11.6

1
  • I think drush is not working properly
    – DarkteK
    Nov 2, 2016 at 3:32

1 Answer 1

4

You don't happen to have a ~/.my.cnf file (which sets the user to root)? MySQL will read that file after the file specified by --defaults-extra-file, and "If multiple instances of a given option are found, the last instance takes precedence".

2
  • Thanks - I'd completely forgotten I'd set that up (and had looked everywhere for an answer but not seen anyone mention it…) Nov 2, 2016 at 19:05
  • You just saved me! I was struggling to figure out why drush wasn't working and this was it. It was a leftover my.cnf file was a previous installation of mysql. May 22, 2017 at 21:28

Your Answer

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

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