Stack Exchange Network
Stack Exchange network consists of 183 Q&A communities including
Stack Overflow
, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this community
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I've installed Drush 7 using Composer and working with Drupal 8 and 7 on Ubuntu 12.04 with PHP 5.4.31, mysql 5.5.38
Drush will
dl
modules and themes just fine but when I want to
en
a module then it gives me the
Drush was not able to start (bootstrap) the Drupal database.
So upon further investigation I did this:
$ drush -v -d sql-cli
Starting Drush preflight. [0.02 sec, 1.15 MB] [preflight]
Cache HIT cid: [debug]
7.0-dev-commandfiles-0-87f720da39665f2c425de5e651f2ac4d [0.05 sec,
1.19 MB]
Bootstrap to phase 0. [0.2 sec, 3.19 MB] [bootstrap]
Bootstrap to phase 0. [0.28 sec, 3.19 MB] [bootstrap]
Found command: sql-cli (commandfile=sql) [0.28 sec, 3.19 MB] [bootstrap]
Calling hook drush_sql_cli [0.56 sec, 3.21 MB] [debug]
Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.56 sec, [bootstrap]
3.22 MB]
Initialized Drupal 8.0-dev root directory at [notice]
/home/wavesailor/My_sites/bootstrap-business [0.62 sec, 3.52 MB]
Cache HIT cid: [debug]
7.0-dev-commandfiles-1-67528d048330f8c38ed66ea20e647906 [0.62 sec,
3.52 MB]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.63 sec, [bootstrap]
3.57 MB]
Initialized Drupal site default at sites/default [0.63 sec, 3.57 MB] [notice]
Cache MISS cid: [debug]
7.0-dev-install_profile-66ecfeb9791a023150773849f1550c5d [0.64 sec,
3.57 MB]
Cache HIT cid: [debug]
7.0-dev-commandfiles-2-027a7d06ad1248d56c7499a21fb8d2df [0.65 sec,
3.57 MB]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.65[bootstrap]
sec, 3.57 MB]
Calling proc_open(mysql --defaults-extra-file=/tmp/drush_ST3u9r --database=bootstrap_business --host=127.0.0.1 --port=3306);
ERROR 1045 (28000): Access denied for user 'my_username'@'localhost' (using password: YES)
Returned from hook drush_sql_cli [0.87 sec, 3.72 MB] [debug]
Command dispatch complete [0.87 sec, 3.71 MB] [notice]
Peak memory usage was 5.21 MB [0.87 sec, 3.7 MB] [memory]
It seems it cannot connect to the database so I did the following:
$ drush sql-connect
mysql --user=my_username --password=my_password --database=bootstrap_business --host=127.0.0.1 --port=3306
$ mysql --user=my_username --password=my_password --database=bootstrap_business --host=127.0.0.1 --port=3306
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 286
Server version: 5.5.38-0ubuntu0.12.04.1 (Ubuntu)
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
I can connect manually to the database with the connection string given by drush.
So then I deleted the .drush
folder in my home directory but that did not help.
I did try this for both Drupal 7 and 8 sites.
So then I downgraded to drush 6 (composer global require drush/drush:6.*
) and drush then worked flawlessly with Drupal 7 sites. I then upgraded to drush 7 (composer global require drush/drush:dev-master
) and it stops working again
Any ideas on how to solve this??
–
–
–
The answer to the problem was that I had a file .my.cnf
in my home directory which I used a while back. It contained the user=username
and the password=old_password
. This was the cause of problem as it contained the correct username but an old password.
Previous drush versions (< 7.x) did not use the mysql option --defaults-extra-file=/tmp/mysql_credentials
to connect to database and that's why the problem didn't exist when I used an older version of drush.
I would have thought that the '--defaults-extra-file=/tmp/mysql_credentials
would supercede the .my.cnf
in my home directory but it doesn't seem to.
One thing which would be useful to help debug this issue it to make drush not delete the /tmp/...
files when you select the -d
option.
Do a drush st database | grep -i connected
.
If you don't get any results, that could mean (in your case) the db credentials on your settings.php is wrong.
The above command tells drush to give a status (st) of your installation, filter results to include only strings containing the word database and finally passing this result to grep to do a case-insensitive search for the word connected. To understand more about drush st
execute a drush help st
.
–
Thanks for contributing an answer to Drupal Answers!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.