Unable to access database

If you use the alias command globally you can then simply run local-socket in the Site Shell.

1 Like

It looks like it’s going out in WP-CLI 2.4.1 which includes db-command 2.0.6: Update mustache dependency and remove patch · wp-cli/wp-cli@ceb1859 · GitHub

https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar still links to 2.4.0 but that shouldn’t be a deal-breaker for us.

2 Likes

Good to know a fix is come soon!

@afragen I still get an error when doing it like in the screenshot below. Am I still doing something wrong?

Well that’s at least a different error.

I assume this is in the Site Shell. If the socket path matches the symlink in the database tab.

Not sure I’ve got much else.

I was finally able to resolve a similar problem I was having with a solution on this post Unable to run Db Export via CLI

don’t know how i missed this earlier but the –socket argument after my wp cli db command totally works. There’s a screenshot on that post that explains it. Good luck!

1 Like

FYI, I had to modify this command to not only escape the dollar-sign in $SOCKET as you have done, but also wrap it in quotation marks because of the spaces in the path. Which is quite strange–I would expect you to have to do the same, but apparently not.

I have a different problem, though
When I create the local-socket alias that you describe and then run it, things are good: I can run WP-CLI db commands without specifying the socket in the command. I would expect that I could save the alias in ~/.bash_profile in order to have it available each time I launch the shell from Local. I have done this, but when I run local-socket I get the error:

bash: local-socket: command not found

Did you do something so that you could save the alias and have it available between site restarts and closing/opening the shell?

@positivejam I’m really not aware that I did anything special to have the alias globally available. I may have created the alias outside of the site shell initially.

You would need to run the command every time you work in a new site shell as the socket would change and you must reference the correct database.

Not sure about the escaping but glad you got it working.

1 Like

I’m not sure which OS you’re on but, you might double check to see if you have a ~/.bashrc file instead.
When you added the alias, did you also do source ~/.bash_profile to update the shell? (edit, didn’t finish this sentence.)

I use zshell, so my file is .zshrc but, I was able to add an alias to my file. Opening a new site shell allowed me to use the alias. As long as the same terminal program is used for your site shell and reads the same .bash_profile, then you should have no issues setting up global alias.

1 Like

That was it!

I’m on mac os. The reason I was so confused was that when I’d open Terminal, .bash_profile would run, but despite adding my alias to .bash_profile, the alias wouldn’t be set in Terminal windows popped by Local. And that was because Local is running .bashrc.

Really, just needed to learn the differences between the two. Thanks folks!

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.