2

Using drush commands to update Drupal 8 Core on a localhost build in MAMP, I've found that drush won't acknowledge my mysql.

From reading a few threads apparently this is due to MAMP's default locations for MYSQL location not being compatible with drush's expectation.

I've followed a few forum suggestions for fixed but so far have not had any luck.

The Latest attempt gives me this permission error:

 [warning] The command 'mysql' is required for preflight but cannot be found. 
Please install it and retry. Drush Commandline Tool 9.2.3

Other attempts:

I followed the suggestion from March 14th on this thread:

https://github.com/drush-ops/drush/issues/3464

which gave me this error:

[info] Executing: mysql --defaults-file=/private/tmp/drush_iBYWVg --database=drupal20180405 --host=localhost --port=3306 --silent < /private/tmp/drush_7T1mwj [info] Executing: mysql --defaults-file=/private/tmp/drush_bvCyn3 --database=drupal20180405 --host=localhost --port=3306 --silent < /private/tmp/drush_a9aRha In Connection.php line 149: [PDOException (2002)] SQLSTATE[HY000] [2002] No such file or directory

Another potential solution I tried came from Chrisblomm's answer on this thread:

Drush cannot connect to MySQL on MAMP?

Unfortunately for me that triggered the first error again:

 [warning] The command 'mysql' is required for preflight but cannot be found. 
Please install it and retry. Drush Commandline Tool 9.2.3

UPDATE: I found a solution here:

Andrew Patton's comments on this thread solved it for me:

https://stackoverflow.com/a/29990624/2639928

Specifically his tips to "define and export mysql and mysqladmin as functions".

Once I added his suggested lines of code to to my Mac's local .bash_profile it then allowed drush to correctly identify the mysql.

This meant I was able to use all the drush commands I needed that had previously triggered drush errors.

Auxiliary Joel
  • 173
  • 1
  • 13
  • perhaps you should post those errors otherwise it could be anything and you will get just wild guesses – GiorgosK Aug 13 '18 at 05:41
  • Hi GiorgoksK, here is the error I receive: [warning] The command 'mysql' is required for preflight but cannot be found. Please install it and retry. Drush Commandline Tool 9.2.3 – Auxiliary Joel Aug 16 '18 at 10:28
  • I followed this suggestion: https://github.com/drush-ops/drush/issues/3464 which gave more errors: [info] Executing: mysql --defaults-file=/private/tmp/drush_iBYWVg --database=drupal20180405 --host=localhost --port=3306 --silent < /private/tmp/drush_7T1mwj [info] Executing: mysql --defaults-file=/private/tmp/drush_bvCyn3 --database=drupal20180405 --host=localhost --port=3306 --silent < /private/tmp/drush_a9aRha In Connection.php line 149: [PDOException (2002)] SQLSTATE[HY000] [2002] No such file or directory – Auxiliary Joel Aug 16 '18 at 10:34
  • I also tried Chrisblomm's steps in this post, but that just gave me the original error again: https://stackoverflow.com/questions/19300996/drush-cannot-connect-to-mysql-on-mamp – Auxiliary Joel Aug 16 '18 at 10:49

2 Answers2

0

Andrew Patton's comments here solved it for me: https://stackoverflow.com/a/29990624/2639928 specifically his tips to "define and export mysql and mysqladmin as functions" once I added that to my mac / user / .bash_profile my drush acknowledged the mysql and I was able to use all the commands I needed that had previously given me drush errors.

Auxiliary Joel
  • 173
  • 1
  • 13
0

I have the same issue in my php container

 [warning] The shell command 'mysql' is required but cannot be found. Please install it and retry.

The mysql client was not installed so to fix it I added mysql client

apt-get install -y default-mysql-client
tomerpacific
  • 4,704
  • 13
  • 34
  • 52
FaTi
  • 29
  • 2