I have a script that I run to create a WordPress website. All runs well until I get to the:
wp core install --title=$client --url=$client.local --admin_user=$clientshort-admin --admin_password=******** --admin_email=********@gmail.com
I get the following:
Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /Applications/MAMP/htdocs/pndesign2/web/wp/wp-includes/wp-db.php on line 1488
Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /Applications/MAMP/htdocs/pndesign2/web/wp/wp-includes/wp-db.php on line 1518
Warning: mysql_connect(): No such file or directory in /Applications/MAMP/htdocs/pndesign2/web/wp/wp-includes/wp-db.php on line 1518
Error: Error establishing a database connection
THanks!
After going round in circles, it was down to the PHP version differences between OSX/MAMP/ and WP-CLI.
Updating your .bash_profile with the version of MAMP solves it – more details here How to override the path of PHP to use the MAMP path?