Local Community

Wp db reset doesn't work correctly with MySQL

Bug Summary

When trying to reset a site using WP CLI I get this error:

$ wp db reset
Are you sure you want to reset the 'local' database? [y/n] y
Error: Failed to get current SQL modes. Reason: '"mysql --no-defaults --no-auto-rehash --batch --skip-column-names --execute="SELECT' is not recognized as an internal or external command,
operable program or batch file.

This is NOT related to: Wp db reset – Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2) - Bugs - Local Community (localwp.com)

Steps to reproduce

Open site shell and try to reset the site.

Environment Info

Describe your environment.

  • What Operating System are you using?
    Windows 10 Pro 21H2
  • What versions of site software (Nginx, Apache, PHP, MySQL) is used?
    PHP 8.0, nginx, MySQL 5.7.28
  • What version of Local is installed?
    6.3.1

Supporting info

Please provide your Local Log. See this Community Forum post for instructions on how to do so:

local-lightning.zip (75.8 KB)

Also having this issue. Can’t run WP-CLI DB commands in the site shell.

Local 6.4.2+6012
Windows 11 Pro 21H2
PHP 8.0.0, MySQL 8.0.16
local-logs3.zip (18.4 KB)

$ wp db reset
Are you sure you want to reset the 'local' database? [y/n] y
Error: Failed to get current SQL modes. Reason: '"mysql --no-defaults --no-auto-rehash --batch --skip-column-names --execute="SELECT' is not recognized as an internal or external command,
operable program or batch file.

The command looks like it’s missing a " at the end.

I don’t think I’m really responsible for that command, I just type wp db reset :wink:

Agreed. But it might point to an issue with WP-CLI. Not really sure.

I’m having this issue as well. Any solution?

I am on Mac OSX 12.5.1 - Local Version 6.4.3+6116

This worked for me…

1 Like

Hi @cmagill -

Thank you for sharing what worked for you & welcome to the Local community!

@slaFFik - have you tried the above?

Thank you!

Sam

@sammunoz Per the original poster, Windows is the OS in question, and Local on Windows doesn’t support/show sockets.

The original poster, and my follow up comment, clearly show a malformed MySQL CLI command - not any issues connecting to the MySQL host.

@sammunoz Don’t know if this helps, but this is what I see when started the shell session:

Setting Local environment variables...
----
WP-CLI:
Warning: PHP Startup: Unable to load dynamic library 'php_imagick.dll' (tried: C:/Users/Ethan/AppData/Local/Programs/Local/resources/extraResources/lightning-services/php-7.4.1+18/bin/win64/ext\php_imagick.dll (The specified module could not be found.), C:/Users/Ethan/AppData/Local/Programs/Local/resources/extraResources/lightning-services/php-7.4.1+18/bin/win64/ext\php_php_imagick.dll.dll (The specified module could not be found.)) in Unknown on line 0
WP-CLI 2.7.1
Composer:
Startup: Unable

Startup: Unable
2.4.2 2022-09-14
stdout is not a tty
PHP:
MySQL:    C:\Users\Ethan\AppData\Local\Programs\Local\resources\extraResources\lightning-services\mysql-8.0.16+6\bin\win64\bin\mysql.exe  Ver 8.0.16 for Win64 on x86_64 (MySQL Community Server - GPL)
----
Launching shell: /usr/bin/bash ...

Some things I notice:

  • No Composer version is output. When I run Composer commands, it uses my globally installed Composer. which php gives me /c/ProgramData/ComposerSetup/bin/composer
  • No PHP version is output, but it does appear to use the PHP version set for this site. which php gives me /c/Users/Ethan/AppData/Local/Programs/Local/resources/extraResources/lightning-services/php-7.4.1+18/bin/win64/php, so that seems correct.

Don’t know if any of that’s helpful.

Hello,
I’m having the same issue :

wp db reset
Are you sure you want to reset the 'local' database? [y/n] y
Error: Failed to get current SQL modes. Reason: '"mysql --no-defaults --no-auto-rehash --batch --skip-column-names --execute="SELECT' is not recognized as an internal or external command,
operable program or batch file.

Environment Info

Windows 11 22H2
PHP 8.1.9, nginx, MySQL 8.0.16
Local 6.5.1+6195
local-lightning.log (1.8 KB)

Relevant issue on GitHub w/ WP-CLI

Thank you, i changed to PHP 7.4 and now I’m getting this error :
Error: Failed to get current SQL modes. Reason: ERROR 2003 (HY000): Can’t connect to MySQL server on ‘localhost’ (10061)
I tried both in local or router mode and get the same error any idea ?