I am having trouble using drush on server setups where the web ( and database ( servers are separate.

drush sql-connect

gives me the correct output of

mysql --user=mysite_user --password=abcdef12345 --database=mysite --host=

If i type this into the console of the web server it connects me to the mysql on the database server correctly, however...


drush cc all --debug

results in the following messages

Executing: mysql --defaults-extra-file=/tmp/drush_j4KBOf --database=mysite --host= --silent  < /tmp/drush_xpMPoI
  ERROR 1045 (28000): Access denied for user 'root'@'' (using password: YES)

It looks like drush is trying to connect using a different set of credentials and failing, i cannot find any my.conf where db credentials are hardcoded.

1 Answer 1


The user name is taken from root's .my.cnf file (normally located in /root/.my.cnf. Either remove the user line from that file, or run Drush as another user than root (which might not have a .my.cnf file.)

Added: The relevant part of the MySQL documentation:

If multiple instances of a given option are found, the last instance takes precedence, with one exception: For mysqld, the first instance of the --user option is used as a security precaution, to prevent a user specified in an option file from being overridden on the command line.

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.