0

I was running an older version of MAMP and found I couldn't install a current version of Wordpress because it required at least PHP version 5.2 so I updated MAMP which now runs 7.4.2. Things seemed to be fine with the update (sites are running) until I tried using interconnect's Search-Replace-DB on a project. Using the GUI, I got an AJAX error. The docs stated in the event of an AJAX error, I should follow the cli instructions; but when I do, I get either one of two errors no matter which approach I take:

db: SQLSTATE[HY000] [2002] Connection refused db: SQLSTATE[HY000] [2002] No such file or directory

My wp-config.php looks like:


/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', 'root');

/** MySQL hostname */
define('DB_HOST', '127.0.0.1');

I read a SO post getting "db: SQLSTATE[HY000] [2002] Connection refused" error on Mac with MAMP and am trying the recommendation to replace the line '#!/usr/bin/php -q' with '#!/usr/bin/env php -q' in the rdb.cli.php file.

The cli commands I've tried: //posts suggest using 8889 but my mamp seems to run on :8888?

//using localhost string
php srdb.cli.php -h localhost -n test -u root -proot -s oldname.org -r localhost:8889 -v true -z

//using ip
php srdb.cli.php -h 127.0.0.1 -n test -u root -proot -s oldname.org -r localhost:8889 -v true -z

//using localhost string
php srdb.cli.php -h localhost -n test -u root -proot -s oldname.org -r localhost:8888 -v true -z

//using ip
php srdb.cli.php -h 127.0.0.1 -n test -u root -proot -s oldname.org -r localhost:8888 -v true -z

//Using path explicitly with ip
/Applications/MAMP/bin/php/php7.4.2/bin/php srdb.cli.php -h 127.0.0.1 -u root -n test -proot -s oldname.org -r localhost:/8888

After changing the line srdb.cli.php, I still can't connect. At this point, I don't know if it's php or mysql that is having an issue, if the db is corrupted, or if the environmental variables/paths/links are off after updating MAMP or how to go about determining these things. Any insights would be greatly appreciated.

user1574371
  • 75
  • 1
  • 1
  • 9

1 Answers1

0

For anyone else encountering this issue, specifying the full location paths for both the MAMP php binary (which will execute the script) and the search-replace-db script in the cli solved the problem. I put the strings to search for and replace with in quotes. I also increased the php timeout limit in wp-config.php with: set_time_limit(3000);

Note that how you specify localhost should be consistent between the options passed to the script and what's in your wp-config.php file (if you use localhost in wp-config, use localhost in the script as well)

/Applications/MAMP/bin/php/php7.4.2/bin/php /Applications/MAMP/htdocs/test/Search-Replace-DB-master/srdb.cli.php -h localhost -u root -proot --port 8889 -n test -s "http://olddomain.com" -r "http://localhost:8888/test" -v true```
user1574371
  • 75
  • 1
  • 1
  • 9