Using WP Commands with Acorn resulting in Database Connection Error

Hi all,

Weird one, not sure exactly why this is happening. Sage 10 with Acorn. Trying to get everything set up to use my theme and I’m having an error The /Applications/XAMPP/xamppfiles/htdocs/cafe/wp-content/cache/acorn/framework/cache directory must be present and writable.

After doing some searching I found an old post that using an acorn publish command fixed the same issue last time. I went to use it and now I’m presented with this error:

wp acorn vendor:publish
PHP Warning:  mysqli_real_connect(): (HY000/2002): No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/cafe/wp-includes/class-wpdb.php on line 2035
Warning: mysqli_real_connect(): (HY000/2002): No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/cafe/wp-includes/class-wpdb.php on line 2035
Error: `No such file or directory`
Error establishing a database connection
This either means that the username and password information in your `wp-config.php` file is incorrect or that contact with the database server at `localhost` could not be established. This could mean your host’s database server is down.

Are you sure you have the correct username and password?
Are you sure you have typed the correct hostname?
Are you sure the database server is running?

If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress support forums. `No such file or directory`

Never had this one pop up before, I renamed my theme folder so I could get back into the backend and I have a perfectly fine database connection so I’m a bit confused as to why this is popping up. Any ideas?

Do other WP-CLI commands (especially ones that want to connect to the database like wp db) execute successfully, or do you get the same error?

All commands seem to cause the same error weirdly

My guess would be that something about the context in which you’re running these commands is preventing WP-CLI from being able to connect to the database. If you were using a VM, I’d probably tell you that you need to run the command from inside the VM, but if you’re on XAMPP that’s presumably not the issue. My guess is that your XAMPP setup is defining the connection to your MySQL database in a way that prevents WP-CLI from being able to connect to it (or perhaps more acturately, prevents it from being able to find out how to connect to it), or WP-CLI isn’t able to access your wp-config.php (or whatever is being used to define connection details for your database). Sometimes that’s as simple as running WP-CLI from the wrong directory. Unfortunately without knowing your setup in more detail it’s very difficult for me to troubleshoot further, but hopefully that can point you in a helpful direction.

Finally managed to figure it after a break. Think there was an issue with my XAMP, removing and reinstalling it seems to have fixed it. Wonder if there was an issue with the install. Thanks for the help!


Weird. As soon as I fix that issue, I get another one and the fix for that reverts the error back to the original one.

The new error I’m getting is cache/acorn/framework/views/.php) Failed to open stream and when I had this issue before running a wp acorn vendor:publish it returns to the original error. Tried to install the error handling but it just gives me some weird messed up page.

I found this article about an issue with wp-cli connecting to the database using MAMP. I realize you’re using XAMP, but thought this might be worth a try.

1 Like