Unable to run Db Export via CLI

Hi all,

Just setup Local and for the most part i’m loving it. I am experiencing an issue when running wp db export though in shell.

I get the following error:

mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) when trying to connect

Also when attempting to connect using Sequel pro I get the following too.

I’m not sure what I’m missing here. I have checked the files in the screenshot and not having any luck on this.

1 Like

Howdy folks,

Curious if we’ve got any update on this. Loving LOCAL so far except for this one little issue
which is actually a big issue in a way.

1 Like

Hey @darraghb

I’m honestly not sure why that isn’t working, but as a workaround you can find the socket on the database tab in Local.

With that, you can add it to the export command if you are using WP CLI.

Something like this:

 wp db export db-backup.sql --socket="/Users/username/Library/Application Support/Local/run/Zz3-D-Hl-/mysqld.sock"

The socket path with be unique to each site.

2 Likes

Cool, that works! Yay! Is there any way of getting the SQL socket address programmatically? I’ve got 3 or 4 users on different platforms (Linux/Mac) and each has different .../run/??????/mysqld.sock – which means I can’t create a universal script for all the users.

Hey Jake

thats brilliant.

Thanks so much for that help. Loving Local too.

This seems like a bug. the workaround above works, but it should use the socket automatically. @clay and team, is there something I’m missing here? I am on the 5.1 beta and got that error.

Thanks for the workaround @jkiley!