0
votes

I have a localhost development environment using MAMP Pro, with a Wordpress website working successfully using PHP 5.6.8. Changing the host to PHP 7.0.13 (and changing nothing else) results in the error:

Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in [edited path]/wp-includes/wp-db.php on line 1538

Error establishing a database connection

This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at localhost:3306. This could mean your host’s database server is down.

Screenshot of Complete Error

wp-config.php definitely has correct username, password, hostname and the database is running. Solutions to similar issues/warnings suggest the MySQL socket path in php.ini file could be wrong, but I have compared that file across the two php versions and they are the same.

I am using the latest versions of MAMP Pro (4.1) and Wordpress (4.7.4), as well as OS X (10.12.4). Also, the website works fine again when changing the host back to PHP 5.6.8.

No idea what else to do/check. Any thoughts are much appreciated.

2

2 Answers

1
votes

Wordpress 4.6 later version is not supported in Php 7.0 So please Reinstall Php 5.6 and check .so working

0
votes

After updating to PHP7 you need to check the path to the mysql.sock.

Open the php.ini file and correct the path

mysql.default_socket = /Applications/MAMP/bin/IDONTKNOW...../mysql.sock