PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, April 2, 2022

[FIXED] Drush cannot locate mysql on localhost MAMP

 April 02, 2022     drupal-8, drush, mamp     No comments   

Issue

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.


Solution

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.



Answered By - Auxiliary Joel
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing