Search code examples
phpdrupaldrupal-7drush

drush si failure user has access, Failed to create database: ERROR 1045 (28000): Access denied for user


I am running the following sets of commands to automatically install a certain drupal website

phpMyAdmin, has a database named x_init_testing, and has a user testing with password secret that can log into it (a manual drupal install is working fine, and there is an access to the db with the user and the password)

First, I am running

mysqladmin -utesting -psecret drop x_init_testing -f
mysqladmin -utesting -psecret create x_init_testing

both of these work fine, and clear the database (which should allow drush to install a new site on it)

then I am running

drush si profileName --db-url=mysql://[email protected]/x_init_testing -y --account-pass=secret

root has a password (i.e., it is not empty) and drush sql connect does work

drush sql-connect
mysql --user=testing --password=secret --database=x_init_testing --host=127.0.0.1 --port=8889

the site is stored on MAMP (i.e., locally on my machine so no network problems)

and my settings.php file is configured with the db */

$databases = array (
  'default' => 
  array (
    'default' => 
    array (
      'database' => 'x_init_testing',
      'username' => 'testing',
      'password' => 'secret',
      'host' => '127.0.0.1',
      'port' => '8889',
      'driver' => 'mysql',
      'prefix' => '',
    ),
  ),
);

Still running the drush si results in

You are about to CREATE the 'x_init_testing' database. Do you want to continue? (y/n): y
Failed to create database: ERROR 1045 (28000): Access denied for user[error]
'root'@'localhost' (using password: NO)

If needed I am using: Drush Version 8.1.6, and it seems that I am using all the required arguments for the si


Solution

  • I think I found the issue, in theory the root user starts with no password, and this is why the command worked on machines that did not set a root password

    changing the si command to :

    drush si profileName --db-url=mysql://root:[email protected]/x_init_testing -y --account-pass=secret