Using drush when database and web server are separate I am having trouble using drush on server setups where the web (111.11.11.1) and database (222.22.22.2) servers are separate.

drush sql-connect


gives me the correct output of

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


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

Running 

drush cc all --debug


results in the following messages

Executing: mysql --defaults-extra-file=/tmp/drush_j4KBOf --database=mysite --host=222.22.22.2 --silent  &lt; /tmp/drush_xpMPoI
  ERROR 1045 (28000): Access denied for user 'root'@'111.11.11.1' (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.
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.