I get this error when I try to create something with WP CLI:
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`. This could mean your host’s database server is down.
But I can open the site with the link: http://localhost:8888/projectname
Go into your
wp-config.php and change your
127.0.0.1 instead of localhost.
Credit goes to Craig Wayne above in the comments.