Unable to access database

I would appreciate some help.

I am trying to access the database via Sequel Pro, or WP CLI to import a .sql file and I cannot do either.

wp db import says:

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

Sequel Pro gets an “unexpected error” when trying to access the database “local”. This happens when using the button in Local to open Sequel Pro, and also when connecting via Socket manually in the app.

I’ve seen these threads:

I’ve tried everything in them except resizing the local machine, which looked long and complicated and might not fix it.

Any command I run such as restarting mysql returns the error No such file or directory and yet my Local site works (at least it did) and I can access the database in the site shell with the mysql command. It seems it just won’t connect properly though the socket.

I’ve also reinstalled Local, and VirtualBox.

I’ve also just installed OS X Mojave, and since then I am getting an error in Local:

Heads-up! Local’s router is having trouble starting. View the router log file for more details.

I’m not sure if this is related, but there is nothing in the log files, so I’m not sure what to do about that.

I was having some other issues, so I wiped and reinstalled my mac os, I’m using Local on a totally fresh install, and still getting the error:

ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

That’s not where the socket is. I don’t know why it’s looking there, but the socket location can be seen in the site’s database tab.

Thanks for replying.

Yes, I know. I don’t know why it was looking there either. Since reinstalling my mac I have reinstalled mysql on it and have progressed from the previous error to:

ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)

As far as I can tell, the socket connection is working, but authentication is not. Not sure how this is possible, since the WP install is working, but I think I’m making progress.

I’m not sure where the authentication is happening, from my.cnf?

1 Like


Sequel Pro still crashes on trying to access the ‘local’ database. And upon running wp db import I get the error:

ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)

However, I can interact with the database using mysql CLI in the site shell and importing the file there worked.

Not sure what is going on, but I least I have one way to interact with the DB outside of WP. I would like to get the Sequel Pro issue fixed so I can more easily browse database values though.


I can confirm that problem also with Local v5 new installation.
Installed new Local. Added new site and can’t access database from Sequel Pro and also importing from command line with WP-CLI dont work.
Only way i accessed database at the moment was that host name in Adminer had to be localhost:3306 - please try @kristarella it this works for you too

If you are using the Local beta you will need to use the Sequel Pro nightlies. Something about MySQL 8 doesn’t work quite right in the release versions.

Thank you will try that.
But why WP-CLI import gives "ERROR 1049 (42000): Unknown database ‘local’ " errors then? The same MySQL 8.0 related?

Well, if the Sequel Pro nightly works, then I’d have to say yes.

@afragen I didn’t realise I was using Local Beta, but I am. The newer Sequel Pro build did work!

@kristjan07 Thanks, weirdly I don’t seem to have Adminer in my Local app

I don’t think Adminer is set up in the beta.

Adminer isn’t there yes. I just downloaded the single file and added it myself to /app/public folder - just to test and get database imported :slight_smile: I love adminer since it’s a single file replacement for phpmyadmin

Hey Everyone –

We’ve been zeroing in on why this is happening and the general issue is that the wp db subcommands use the --no-defaults param which blocks out the custom MySQL config we provide.

There is a solution but we ran into major issues when trying to implement it on Windows so we’re still working on a way to implement this in a way that works across the various environments.

In terms of a workaround, as @kristarella mentioned, you should be able to do some of the basic things within the terminal using the plain mysql command (as opposed to wp db <subcommand> or connect with a SQL client to do the work.

For reference, here are some examples of common things that can be done on the cli. The parameters are using the default from the “Database” tab within Local.

Import DB

Instead of:

wp db import database.sql


mysql -u root -proot local < database.sql 

Export DB

Instead of:

wp db export


mysqldump -u root -proot local > database.sql

Ben, thanks for much for this. I found this thread when trying to import a new db into an existing local (beta 5.x) site. The mysql commands worked like charm. Woot!

1 Like

I’m using Local 5.2.1+2165 and I’m still not able to run wp db commands or access Adminer. I’m using Windows 10.

We use WP Engine and I attempted to connect to one of our sites and migrate it down. Unfortunately, the website runs multisite, which doesn’t appear to work with Local. Then I tried to do it manually by taking a backup and importing the files and DB. Unfortunately, that approach is failing too since I can’t use the wp search-replace command. It looks like the new version of Local won’t work for us at the moment.

If anyone has any tips I’d love to hear them. Thanks a ton.

Currently, the wp db commands don’t work with Local. This is a known issue and our team submitted a patch to WP-CLI. The PR has since been merged and is pending release.

In the meantime, @ben.turner’s pointers above should do the trick.

As far as multisite goes, pushing and pulling isn’t supported, but you should still be able to get up-and-running with multisite.

If you create a brand-new site in Local with multisite, does it function? If so, importing using mysql -u root -proot local < database.sql should do the trick. After that, you should be able to run wp search-replace to update the domain in Local.


Thanks a lot for the input Clay. We’ll give this a shot and see how it goes.

Any updates here? I just recently upgraded to Lightning and had to start fresh since my old version of Local broke. Having to reinstall all of my sites without wp cli is going to be a major chore.

wp-cli accepted our patch and this latest version is included in Local 5.2.5

Could you give that update a go and let me know if you’re able to use wp-cli properly?

1 Like

Thanks for responding! I just installed that version today and I’m seeing that mysql error.

I’m running version 5.25+2498. Here’s what I’m seeing when I open up a shell and try a db command in wp cli. i was able to do a search-replace with wp cli but it appears the db actions are still broken. at least for me.

/Users/jlovell/Library/Application\ Support/Local/ssh-entry/Yo0avju8v.sh; exit
Last login: Mon Feb 24 16:03:33 on ttys003
➜  ~ /Users/jlovell/Library/Application\ Support/Local/ssh-entry/Yo0avju8v.sh; exit
-n -e
Setting Local environment variables...
WP-CLI: WP-CLI 2.4.0
PHP:    7.3.5
MySQL:  mysql  Ver 8.0.16 for macos10.14 on x86_64 (MySQL Community Server - GPL)
Launching shell: /bin/zsh ...
➜  public git:(countdown-timer) wp db reset --yes
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)