When I start any site, right click open site shell and execute:
Works:
wp db check
wp db export (it was a problem in the past apparently)
Gives error:
wp db query "SHOW TABLES;" (any query)
wp db reset --yes
wp db clean --yes
The error itself:
So when I run wp db reset --yes --debug the error reads as follows:
Debug (bootstrap): Running command: db reset (0.163s)
Debug (db): Final MySQL command: /usr/bin/env mysql --no-defaults --no-auto-rehash --batch --skip-column-names --execute='SELECT @@SESSION.sql_mode' --host='localhost' --user='root' --default-character-set='utf8' (0.166s)
Error: Failed to get current SQL modes. Reason: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
When the command -found in the debug output- is fun manually it also gives the error.
It does work when appending --socket=PATHGIVENBYLOCAL (and -proot cli handles that by itself).
Or when I run the command and remove the --no-defaults flag.
Not sure if this is helpfull…
System Details
I’m on Local 6.1.0 (I only started on this today, so I havn’t tried other versions)
my Laptop runs Ubuntu 21.04
As per the WordPress core documentation, and since Local WP app uses MySQL sockets, consider modifying your wp-config.php to include the use of MySQL Sockets.
MYSQL SOCKETS OR PIPES
If your host uses Unix sockets or pipes, adjust the DB_HOST value in the wp-config.php file accordingly.
define( 'DB_HOST', '127.0.0.1:/var/run/mysqld/mysqld.sock' ); // or
define( 'DB_HOST', 'localhost:/var/run/mysqld/mysqld.sock' ); // or
define( 'DB_HOST', 'example.tld:/var/run/mysqld/mysqld.sock' );
Replace:/var/run/mysqld/mysqld.sock with the socket or pipe information provided by your host.
You can find the MySQL socket for your current local site here:
Local WP App → Local Sites → Install Name → Database Tab → Socket.
Copy/paste that into your DB_HOST constant definition in your wp-config.php