ultraloveninja
ultraloveninja

Reputation: 2139

wp core install cannot connect to database with WP-CLI

I don't know why it's doing this but for some reason, when I try to install WordPress with WP CLI with wp core install, it cannot complete and throws the Error: Error establishing a database connection error.

I've checked everything and I'm not sure what the issue is. I'm using MAMP PRO and all of the settings in the wp-config.php file are correct.

I'm connecting via localhost and the database is created just fine and I can see that there.

I've tried changing localhost to 127.0.0.1 in the wp-config file, but that borks outright.

Username and Password to connect are the default of root and root.

If I go to the local URL directly, I can see the WP install screen and then after I select the language, it redirects me to the setup where I can name the site, username, password, etc. I never see the DB connection info at all.

I did have to set this in my .zshrc file: export PATH=$PATH:/Applications/MAMP/Library/bin/ cause it was having an issue when creating the wp-config file with wp config create, but once I added that, it was able to create the wp-config file without errors, so maybe that might be an issue? But overall, I'm stumped. I had a bash script that was working to generate all of this automatically, but now I'm not sure what the issue could be since it appears everything is setup correctly.

Upvotes: 0

Views: 1123

Answers (1)

Nagesh
Nagesh

Reputation: 141

If you're running on Mac and using MAMP, update hostname in wp-config.php

define( 'DB_HOST', 'localhost:/Applications/MAMP/tmp/mysql/mysql.sock' );

Upvotes: 4

Related Questions