Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drush uses --defaults-extra-file which is overrided by users .my.cnf #1505

Closed
jkolkka opened this issue Jul 23, 2015 · 2 comments
Closed

Drush uses --defaults-extra-file which is overrided by users .my.cnf #1505

jkolkka opened this issue Jul 23, 2015 · 2 comments

Comments

@jkolkka
Copy link

jkolkka commented Jul 23, 2015

Drush uses --defaults-extra-file when connecting to database for storing username&password. If current user has .my.cnf in his/her home folder it will override --defaults-extra-file.

Example:
settings.php found in sites/default

$databases = array (
  'default' =>
  array (
    'default' =>
    array (
      'database' => 'dev_base',
      'username' => 'dev_user',
      'password' => 'dev_password',
      'host' => 'localhost',
      'port' => '',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

~/.my.cnf

[client]
user="my_user"
password="my_password"

When connecting to MySQL drush will create tmp file with following context:

#This file was written by Drush's Sqlmysql.inc.
[client]
user="dev_user"
password="dev_password"

And it uses it like:
mysql --defaults-extra-file=<previously created tmp file> --database=dev_base --host=localhost --silent

Because .my.cnf overrides --defaults-extra-file previous command will try to connect with user my_user and if my_user doesn't have permissions to access database drush will fail to connect to database.

@weitzman
Copy link
Member

Honoring my.cnf is by design. If you dont want it, delete that file.

@minerva-atrix
Copy link

This is not a good enough answer. Scripts on the server setups I have already use .my.cnf for doing a lot of tasks. Drupal's database is on another machine. Drush needs a way to disable this functionality and it's bad it was ever added. It's been very disruptive see:
https://www.drupal.org/project/drush/issues/2852233
#2750
#2183

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants