Resolve Drush command not found (Mysql Gone Away)

September 30, 2021

Drush was reporting that a command was not found.

For example, running the drush command for a config export:

drush cex

was resulting in an error: “Command cex was not found.”

“Drush cex command not found” screenshot

Running debug gave some additional information, which included “Unable to connect to database with message: SQLSTATE[HY000] [2006] MySQL server has gone away.”

Drush debug info screenshot

To solve this I increased the max_allowed_packet size in the mysql .cnf file.

My local valet setup uses mysql running via homebrew. So for me the file was located in:


If you can’t find yours, I had success running:

mysql —help | grep cnf

After adding:


and restarting mysql

brew services restart mysql@5.7

If you aren’t running the same version of mysql through homebrew, you can find your brew version using:

brew services list