I have a bash script that I want to use to be able to configure a drupal site without having to go through the browser screens.

My setup is using XAMPP on MAC OS X with PHP

Directory for my files are /Applications/XAMPP/xamppfiles/htdocs/zinco

I've set up drush using composer.

The following command:

drush site-install standard --db-url='mysql://**phpmyadminusername**:**phpmyadminpassword**@**websitename**' --site-name=**websitename** --debug

Returns the errors:

Starting Drush preflight. [0.01 sec, 2.18 MB]                        [preflight]
Loading drushrc "/Users/chris/.drush/drushrc.php" into "home.drush"  [bootstrap]
scope. [0.01 sec, 2.18 MB]
Cache HIT cid: 7.1.0-commandfiles-0-db580a5f73406ff96a3c32b2bade2057     [debug]
[0.02 sec, 2.24 MB]
Bootstrap to phase 0. [0.09 sec, 6.16 MB]                            [bootstrap]
Bootstrap to phase 1. [0.09 sec, 6.16 MB]                            [bootstrap]
Drush bootstrap phase : bootstrap_drupal_root() [0.09 sec, 6.52 MB]  [bootstrap]
Initialized Drupal 7.41 root directory at                               [notice]
/Applications/XAMPP/xamppfiles/htdocs/zinco/blah [0.1 sec, 6.52 MB]
Find command files for phase 1 (max=1) [0.1 sec, 4.58 MB]                [debug]
Cache HIT cid: 7.1.0-commandfiles-1-388d122ebce884666d6793a66ef4f7e2     [debug]
[0.1 sec, 4.58 MB]
Found command: site-install (commandfile=site_install) [0.1 sec, 4.58[bootstrap]
Calling hook drush_core_site_install_validate [0.14 sec, 6.55 MB]        [debug]
Returned from hook drush_core_site_install_validate [0.14 sec, 6.56      [debug]
Calling hook drush_core_pre_site_install [0.14 sec, 6.56 MB]             [debug]
Cache MISS cid: 7.1.0-alias-path--ba3c3f210d58349a27067f15d6ee74a3       [debug]
[0.15 sec, 6.67 MB]
sql-query: SELECT 1; [0.16 sec, 6.67 MB]                             [status]
Executing: mysql --defaults-extra-file=/private/tmp/drush_rUKuqF --database=blah --host= --silent  < /private/tmp/drush_BtklU5 > /dev/null
You are about to CREATE the 'blah' database. Do you want to continue? (y/n): y
Sites directory                                                         [notice]
already exists - proceeding. [9.69 sec, 6.67 MB]
Drush bootstrap phase : bootstrap_drupal_site() [9.69 sec, 6.68 MB]  [bootstrap]
Initialized Drupal site default at sites/default [9.69 sec, 6.68 MB]    [notice]
Find command files for phase 2 (max=) [9.7 sec, 4.73 MB]                 [debug]
Cache MISS cid:                                                          [debug]
7.1.0-install_profile-66ecfeb9791a023150773849f1550c5d [9.7 sec, 4.73
Cache HIT cid: 7.1.0-commandfiles-2-adcbc259623838c285e92ee0febd23c7     [debug]
[9.7 sec, 4.74 MB]
sql-query: SELECT 1; [9.7 sec, 4.74 MB]                              [status]
Executing: mysql --defaults-extra-file=/private/tmp/drush_CHP0QP --database=blah --host= --silent  < /private/tmp/drush_LYzbtS > /dev/null
sql-query: DROP DATABASE IF EXISTS blah; CREATE DATABASE blah        [status]
/*!40100 DEFAULT CHARACTER SET utf8 */; [9.71 sec, 4.74 MB]
Executing: mysql --defaults-extra-file=/private/tmp/drush_iWxNeP --database=information_schema --host= --silent  < /private/tmp/drush_8im4te
  sh: mysql: command not found
Returned from hook drush_core_pre_site_install [9.72 sec, 4.73 MB]       [debug]
Calling hook drush_core_site_install [9.72 sec, 4.74 MB]                 [debug]
Starting Drupal installation. This takes a while. Consider using the [ok]
--notify global option. [9.72 sec, 5.03 MB]
Calling install_drupal(Array) [9.72 sec, 5.03 MB]                        [debug]
exception 'Exception' with message 'Resolve all issues below to      [error]
continue the installation. For help configuring your database server,
see the <a
handbook</a>, or contact your hosting provider.<p
class="error">Failed to connect to your database server. The server
reports the following message: <em>SQLSTATE[HY000] [2002] Connection
refused</em>.<ul><li>Is the database server running?</li><li>Does the
database exist, and have you entered the correct database
name?</li><li>Have you entered the correct username and
password?</li><li>Have you entered the correct database
hostname?</li></ul></p>' in
Stack trace:
install_run_task(Array, Array)
#2 /Users/chris/.composer/vendor/drush/drush/includes/drush.inc(719):
#3 /Users/chris/.composer/vendor/drush/drush/includes/drush.inc(705):
drush_call_user_func_array('install_drupal', Array)
drush_op('install_drupal', Array)
drush_core_site_install_version('standard', Array)
#6 [internal function]: drush_core_site_install('standard')
call_user_func_array('drush_core_site...', Array)
_drush_invoke_hooks(Array, Array)
#9 [internal function]: drush_command('standard')
call_user_func_array('drush_command', Array)
#12 /Users/chris/.composer/vendor/drush/drush/drush.php(70):
#13 /Users/chris/.composer/vendor/drush/drush/drush.php(11):
#14 {main} [9.93 sec, 11.64 MB]
Command dispatch complete [9.93 sec, 11.58 MB]                          [notice]
 Timer  Cum (sec)  Count  Avg (msec) 
 page   0.21       1      210.03

Can anyone advice me on how to get by this problem?

I'm not sure whether i'm putting in the right credentials to access mysql/phpmymadin, it's quite confusing. If someone could possibly walk me through them, that would be great.

Thanks in advance.

1 Answer 1


sh: mysql: command not found

Either mysql is not installed at all, or the mysql cli tool is not on your $PATH.

  • 1
    I've added export PATH="/Applications/XAMPP/xamppfiles/bin:$PATH" to my bash_profile which I obtained from this answer.. stackoverflow.com/a/5830108/1060051 could you expand to agree/disagree? Thanks
    – cwiggo
    Commented Dec 2, 2015 at 15:25
  • If your addition to the PATH allows Bash and Drush to find mysql, then I certainly agree. If Bash and Drush still cannot find mysql after you have modified your bash_profile, try sourcing it (source ~/.bash_profile) and try again. If that does not work, check to see whether or not there is a program called mysql in the location you selected. Regretfully, I cannot tell you what path your mysql tools were installed to, because I do not know. Commented Dec 2, 2015 at 16:28
  • Yes, that is all I need to know. If you append your answer with the information you've given me in the previous, I will mark it as the answer. Your comment has given me guidance to a solution. Thanks.
    – cwiggo
    Commented Dec 2, 2015 at 16:43
  • How to set the PATH is off-topic for Drupal answers. Commented Dec 2, 2015 at 17:12

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.