Hello,
I have just set up Valet+ (and WP-CLI Valet Command). Great time saver! I am able to create sites just fine.
There are a couple of problems though:
1) The documentation says that default mysql root user's password is root. But in my case, it doesn't work. Only empty/blank password works.
2) There are warnings and errors appearing when I run valet db ls:
PHP Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in /Users/sridharkatakam/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 172
Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in /Users/sridharkatakam/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 172
Failed to connect to database
PHP Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given in /Users/sridharkatakam/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 233
Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given in /Users/sridharkatakam/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 233
PHP Fatal error: Uncaught Error: Call to a member function query() on boolean in /Users/sridharkatakam/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php:234
Stack trace:
#0 /Users/sridharkatakam/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php(256): Valet\Mysql->getDatabases()
#1 /Users/sridharkatakam/.composer/vendor/weprovide/valet-plus/cli/includes/facades.php(28): Valet\Mysql->listDatabases()
#2 /Users/sridharkatakam/.composer/vendor/weprovide/valet-plus/cli/valet.php(428): Facade::__callStatic('listDatabases', Array)
#3 [internal function]: Silly\Application->{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), 'ls', NULL, NULL)
#4 /Users/sridharkatakam/.composer/vendor/php-di/invoker/src/Invoker.php(82): call_user_func_array(Object(Closure), Array)
#5 /Users/sridharkatakam/.composer/vendor/mnapoli/silly/src/Application.php(95): Invoker\Invoker->call(Object(Closure), Array)
#6 [internal function]: Silly\Application->Silly\{closure}(Object(Sy in /Users/sridharkatakam/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 234
Fatal error: Uncaught Error: Call to a member function query() on boolean in /Users/sridharkatakam/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php:234
Stack trace:
#0 /Users/sridharkatakam/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php(256): Valet\Mysql->getDatabases()
#1 /Users/sridharkatakam/.composer/vendor/weprovide/valet-plus/cli/includes/facades.php(28): Valet\Mysql->listDatabases()
#2 /Users/sridharkatakam/.composer/vendor/weprovide/valet-plus/cli/valet.php(428): Facade::__callStatic('listDatabases', Array)
#3 [internal function]: Silly\Application->{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), 'ls', NULL, NULL)
#4 /Users/sridharkatakam/.composer/vendor/php-di/invoker/src/Invoker.php(82): call_user_func_array(Object(Closure), Array)
#5 /Users/sridharkatakam/.composer/vendor/mnapoli/silly/src/Application.php(95): Invoker\Invoker->call(Object(Closure), Array)
#6 [internal function]: Silly\Application->Silly\{closure}(Object(Sy in /Users/sridharkatakam/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 234
Could this be because I did not install Composer using Homebrew? I already had Composer installed globally using https://getcomposer.org/doc/00-intro.md#globally prior to installing Valet+. So I skipped that step during Valet+ installation.
Any help is appreciated.
Sounds like https://github.com/weprovide/valet-plus/blob/83ae224c9f1f6e287c3b8504452963208be8fb46/cli/Valet/Mysql.php#L151-L153 was not triggered correctly. You can manually run mysqladmin -u root --password='' password root and it'll work 👌 This is not related to composer but rather to homebrew which tells us that mysql was started when it's not booted up yet
Thanks @timneutkens
I ran
mysqladmin -u root --password='' password root
and it certainly made things better. I can now see the table of databases with these warnings appear above the table:
PHP Warning: chown(): parameter 2 should be string or integer, boolean given in /Users/sridharkatakam/.composer/vendor/weprovide/valet-plus/cli/Valet/Filesystem.php on line 258
Warning: chown(): parameter 2 should be string or integer, boolean given in /Users/sridharkatakam/.composer/vendor/weprovide/valet-plus/cli/Valet/Filesystem.php on line 258
@srikat great 👍 as to your other issue https://github.com/weprovide/valet-plus/issues/58 is tracking this.
I fixed it, using these commands:
valet stop
brew uninstall mysql
sudo rm -rf /usr/local/var/mysql/*
valet install
valet db ls
I'm having the same issue with a little variation. I run the command with the error.
valet db create
PHP Warning: mysqli::__construct(): (HY000/2002): No such file or directory in /Users/lucas/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 172
Warning: mysqli::__construct(): (HY000/2002): No such file or directory in /Users/lucas/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 172
Failed to connect to database
PHP Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given in /Users/lucas/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 205
Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given in /Users/lucas/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 205
PHP Fatal error: Uncaught Error: Call to a member function query() on boolean in /Users/lucas/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php:207
Stack trace:
#0 /Users/lucas/.composer/vendor/weprovide/valet-plus/cli/includes/facades.php(28): Valet\Mysql->createDatabase('lucas')
#1 /Users/lucas/.composer/vendor/weprovide/valet-plus/cli/valet.php(480): Facade::__callStatic('createDatabase', Array)
#2 [internal function]: Silly\Application->{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), 'create', NULL, NULL)
#3 /Users/lucas/.composer/vendor/php-di/invoker/src/Invoker.php(82): call_user_func_array(Object(Closure), Array)
#4 /Users/lucas/.composer/vendor/mnapoli/silly/src/Application.php(85): Invoker\Invoker->call(Object(Closure), Array)
#5 [internal function]: Silly\Application->Silly\{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /Users/lucas/.composer/vendor/symfony/console/Co in /Users/lucas/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 207
Fatal error: Uncaught Error: Call to a member function query() on boolean in /Users/lucas/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php:207
Stack trace:
#0 /Users/lucas/.composer/vendor/weprovide/valet-plus/cli/includes/facades.php(28): Valet\Mysql->createDatabase('lucas')
#1 /Users/lucas/.composer/vendor/weprovide/valet-plus/cli/valet.php(480): Facade::__callStatic('createDatabase', Array)
#2 [internal function]: Silly\Application->{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), 'create', NULL, NULL)
#3 /Users/lucas/.composer/vendor/php-di/invoker/src/Invoker.php(82): call_user_func_array(Object(Closure), Array)
#4 /Users/lucas/.composer/vendor/mnapoli/silly/src/Application.php(85): Invoker\Invoker->call(Object(Closure), Array)
#5 [internal function]: Silly\Application->Silly\{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /Users/lucas/.composer/vendor/symfony/console/Co in /Users/lucas/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 207
Then I run mysqladmin with an error.
mysqladmin -u root --password='' password root
zsh: command not found: mysqladmin
So when I search I find a few locations but am assuming that the Cellar is the correct mysqladmin. When I run the command I get a different error.
/usr/local/Cellar/[email protected]/5.7.22/bin/mysqladmin -u root --password='' password root
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
Valet+ was working here (sort of – it was quite inconsistent, see #218) for a while.
However, MySQL stopped working overnight, when I and my MacBook were sleeping.
Since then, nada.
valet db ls
Password:
PHP Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in /Users/philby/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 284
Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in /Users/philby/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 284
Failed to connect to database
PHP Warning: mysqli_real_escape_string(): Couldn't fetch mysqli in /Users/philby/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 305
Warning: mysqli_real_escape_string(): Couldn't fetch mysqli in /Users/philby/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 305
PHP Fatal error: Uncaught Error: Call to a member function query() on boolean in /Users/philby/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php:264
Stack trace:
#0 /Users/philby/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php(237): Valet\Mysql->query(NULL)
#1 /Users/philby/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php(227): Valet\Mysql->getDatabases()
#2 /Users/philby/.composer/vendor/weprovide/valet-plus/cli/includes/facades.php(28): Valet\Mysql->listDatabases()
#3 /Users/philby/.composer/vendor/weprovide/valet-plus/cli/valet.php(492): Facade::__callStatic('listDatabases', Array)
#4 [internal function]: Silly\Application->{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), 'ls', NULL, NULL)
#5 /Users/philby/.composer/vendor/php-di/invoker/src/Invoker.php(82): call_user_func_array(Object(Closure), Array)
#6 /Users/philby/.composer/vendor/mnapoli/silly/src/Application.php(85): Invoker\Invoker->call(Object(Closure), Array)
#7 /Users/ in /Users/philby/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 264
Fatal error: Uncaught Error: Call to a member function query() on boolean in /Users/philby/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php:264
Stack trace:
#0 /Users/philby/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php(237): Valet\Mysql->query(NULL)
#1 /Users/philby/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php(227): Valet\Mysql->getDatabases()
#2 /Users/philby/.composer/vendor/weprovide/valet-plus/cli/includes/facades.php(28): Valet\Mysql->listDatabases()
#3 /Users/philby/.composer/vendor/weprovide/valet-plus/cli/valet.php(492): Facade::__callStatic('listDatabases', Array)
#4 [internal function]: Silly\Application->{closure}(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput), 'ls', NULL, NULL)
#5 /Users/philby/.composer/vendor/php-di/invoker/src/Invoker.php(82): call_user_func_array(Object(Closure), Array)
#6 /Users/philby/.composer/vendor/mnapoli/silly/src/Application.php(85): Invoker\Invoker->call(Object(Closure), Array)
#7 /Users/ in /Users/philby/.composer/vendor/weprovide/valet-plus/cli/Valet/Mysql.php on line 264
Uninstalled Valet+, reinstalled Valet+ with MariaDB, uninstalled Valet+, removed Composer, reinstalled Composer, reinstalled Valet+ -- still the same error.
Maybe someone thought of this beforehand: #4 [internal function]: Silly\Application->{closure} ?
Anyway, moving disappointedly back to Docker.
I ran into a situation where valet was failing to reset mysql root password (as suggested above https://github.com/weprovide/valet-plus/issues/56#issuecomment-326643406). It turned out that mysql commands wouldn't work at all! I needed to run brew link mysql, specifically brew link --force [email protected]. After this, I reran valet install and everything was setup correctly.
@rafaelstz Solution worked for me.
It seems that you need to uninstall mysql if you have an existing mysql installation on your computer.
I think valet cannot set a pw for this installation because it is not the owner. So you have to uninstall it and let valet reinstall mysql.
Note: On uninstalling I ended with
➜ ~ brew uninstall mysql
Error: No such keg: /usr/local/Cellar/mysql
solved this by using
➜ ~ brew uninstall [email protected]
You can find your specific mysql package with "brew ls".
For reference, I had to forcefully remove all traces of MySQL and reinstall with Valet Plus to get it working again. I documented the issue and processes here:
Most helpful comment
I fixed it, using these commands: