Valet-plus: MySQL not found on installation from scratch

Created on 28 Jun 2018  Â·  4Comments  Â·  Source: weprovide/valet-plus

Hi everyone,

In addition to the errors previously reported, I reinstalled my Macbook and installed Valet Plus from scratch.

After experiencing no errors on the installation, the following error was returned on the console when I tried to access MySQL:
mysql: command not found

I tried by running valet fix and valet install but that didn't fix the issue.

I installed MySQL via multiple methods, and I always had the following errors:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES).

I've seen other Valet Plus users reporting the same using on the MageChat Slack channel.

Is anyone else experiencing this issue?

Most helpful comment

I ran into this issue when my computer needed to restart. Apparently I had at some point updated homebrew and caused mysql version 8 to be installed.

This perplexed me for quite a bit, but I was able to get my database working properly by swapping in mariadb in place of mysql. Here are the steps I took:

  1. brew uninstall mysql - Remove mysql
  2. brew install mariadb - Install mariadb instead
  3. cp ~/.composer/vendor/weprovide/valet-plus/cli/stubs/my.cnf /usr/local/etc/my.cnf.d/valet.cnf - This allows the default valet+ configuration to be read by mariadb.
  4. brew services restart mariadb - Restarts mariadb to reload the configuration.

A few seconds after the final step, I was able to run mysql -uroot and connect immediately. My existing Valet+ sites also resumed working.

My Valet+ sites happen to be running WordPress, and this was the stack trace that I initially saw that made me realize there was some problem with my DB:

PHP Warning:  mysqli_real_connect(): (HY000/2002): No such file or directory in /Users/jpry/Sites/<site>/wp/build/wp-includes/wp-db.php on line 1611
PHP Stack trace:
PHP   1. {main}() /Users/jpry/.composer/vendor/weprovide/valet-plus/server.php:0
PHP   2. require() /Users/jpry/.composer/vendor/weprovide/valet-plus/server.php:117
PHP   3. require() /Users/jpry/Sites/<site>/wp/build/index.php:17
PHP   4. require_once() /Users/jpry/Sites/<site>/wp/build/wp-blog-header.php:13
PHP   5. require_once() /Users/jpry/Sites/<site>/wp/build/wp-load.php:42
PHP   6. require_once() /Users/jpry/Sites/<site>/wp/wp-config.php:42
PHP   7. require_wp_db() /Users/jpry/Sites/<site>/wp/build/wp-settings.php:109
PHP   8. wpdb->__construct($dbuser = *uninitialized*, $dbpassword = *uninitialized*, $dbname = *uninitialized*, $dbhost = *uninitialized*) /Users/jpry/Sites/<site>/wp/build/wp-includes/load.php:426
PHP   9. wpdb->db_connect($allow_bail = *uninitialized*) /Users/jpry/Sites/<site>/wp/build/wp-includes/wp-db.php:638
PHP  10. mysqli_real_connect(*uninitialized*, *uninitialized*, *uninitialized*, *uninitialized*, *uninitialized*, *uninitialized*, *uninitialized*, *uninitialized*) /Users/jpry/Sites/<site>/wp/build/wp-includes/wp-db.php:1611

All 4 comments

Yes. Mysql shows that it is being toggled via Valet commands. However, valet db has an error and my system doesn't seem to think mysql is installed; back to Mamp Pro I guess.

➜ ~ valet db

In valet.php line 576:

Command not found

Looking into this is the first thing on my list. It's related to the brew change of MySQL and in my opinion should valet-plus never use formula's without a suffixed version E.G: "[email protected]" preferred over "mysql".

I ran into this issue when my computer needed to restart. Apparently I had at some point updated homebrew and caused mysql version 8 to be installed.

This perplexed me for quite a bit, but I was able to get my database working properly by swapping in mariadb in place of mysql. Here are the steps I took:

  1. brew uninstall mysql - Remove mysql
  2. brew install mariadb - Install mariadb instead
  3. cp ~/.composer/vendor/weprovide/valet-plus/cli/stubs/my.cnf /usr/local/etc/my.cnf.d/valet.cnf - This allows the default valet+ configuration to be read by mariadb.
  4. brew services restart mariadb - Restarts mariadb to reload the configuration.

A few seconds after the final step, I was able to run mysql -uroot and connect immediately. My existing Valet+ sites also resumed working.

My Valet+ sites happen to be running WordPress, and this was the stack trace that I initially saw that made me realize there was some problem with my DB:

PHP Warning:  mysqli_real_connect(): (HY000/2002): No such file or directory in /Users/jpry/Sites/<site>/wp/build/wp-includes/wp-db.php on line 1611
PHP Stack trace:
PHP   1. {main}() /Users/jpry/.composer/vendor/weprovide/valet-plus/server.php:0
PHP   2. require() /Users/jpry/.composer/vendor/weprovide/valet-plus/server.php:117
PHP   3. require() /Users/jpry/Sites/<site>/wp/build/index.php:17
PHP   4. require_once() /Users/jpry/Sites/<site>/wp/build/wp-blog-header.php:13
PHP   5. require_once() /Users/jpry/Sites/<site>/wp/build/wp-load.php:42
PHP   6. require_once() /Users/jpry/Sites/<site>/wp/wp-config.php:42
PHP   7. require_wp_db() /Users/jpry/Sites/<site>/wp/build/wp-settings.php:109
PHP   8. wpdb->__construct($dbuser = *uninitialized*, $dbpassword = *uninitialized*, $dbname = *uninitialized*, $dbhost = *uninitialized*) /Users/jpry/Sites/<site>/wp/build/wp-includes/load.php:426
PHP   9. wpdb->db_connect($allow_bail = *uninitialized*) /Users/jpry/Sites/<site>/wp/build/wp-includes/wp-db.php:638
PHP  10. mysqli_real_connect(*uninitialized*, *uninitialized*, *uninitialized*, *uninitialized*, *uninitialized*, *uninitialized*, *uninitialized*, *uninitialized*) /Users/jpry/Sites/<site>/wp/build/wp-includes/wp-db.php:1611

Closing this issue since it should be fixed by https://github.com/weprovide/valet-plus/pull/198

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SnowCommerceBrand picture SnowCommerceBrand  Â·  4Comments

Igloczek picture Igloczek  Â·  4Comments

MikeYV picture MikeYV  Â·  4Comments

NurdinDev picture NurdinDev  Â·  4Comments

kupoback picture kupoback  Â·  4Comments