zsh: command not found: mysql. MySQL is not compatible for zsh?

Viewed 2022

Isn't possible to install MySQL in zsh in macOS?

I have been trying to install MySQL on my Mac.

zsh: command not found: mysql

Should I give up setting MySQL on zsh and try to do in bash?


% brew install mysql@5.7
==> Downloading https://ghcr.io/v2/homebrew/core/mysql/5.7/manifests/5.7.32-2
Already downloaded: /Users/stackover/Library/Caches/Homebrew/downloads/abe6a0a4787f4c4bd9c6d14e27d98d868c1f0f619cbbba601e8225--mysql@5.7-5.7.32-2.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/mysql/5.7/blobs/sha256:82867504
Already downloaded: /Users/stackover/Library/Caches/Homebrew/downloads/8db250bb2773af3411c71cf86232ed647cdf9366670c716c52574d--mysql@5.7--5.7.32.arm64_big_sur.bottle.2.tar.gz
==> Pouring mysql@5.7--5.7.32.arm64_big_sur.bottle.2.tar.gz
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

mysql@5.7 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.

If you need to have mysql@5.7 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc

For compilers to find mysql@5.7 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/mysql@5.7/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/mysql@5.7/include"


To have launchd start mysql@5.7 now and restart at login:
  brew services start mysql@5.7
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/mysql@5.7/bin/mysql.server start
==> Summary
  /opt/homebrew/Cellar/mysql@5.7/5.7.32: 319 files, 233.7MB
stackover@stackoverjunoMacBook-Air ~ %   echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
stackover@stackoverjunoMacBook-Air ~ % myql --version
zsh: command not found: myql
stackover@stackoverjunoMacBook-Air ~ % mysql --version
zsh: command not found: mysql
stackover@stackoverjunoMacBook-Air ~ %   export LDFLAGS="-L/opt/homebrew/opt/mysql@5.7/lib"
stackover@stackoverjunoMacBook-Air ~ %   export CPPFLAGS="-I/opt/homebrew/opt/mysql@5.7/include"
 echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc

export LDFLAGS="-L/opt/homebrew/opt/mysql@5.7/lib"

I checked if it installed:

stackover@stackoverjunoMacBook-Air ~ % mysql --version     

but

zsh: command not found: mysql

I also tried this:

stackover@stackoverjunoMacBook-Air ~ % mysql -uroot
zsh: command not found: mysql 
1 Answers
stackover@stackoverjunoMacBook-Air ~ %   echo 'export PATH="/opt/homebrew/opt/mysql@5.7/bin:$PATH"' >> ~/.zshrc
stackover@stackoverjunoMacBook-Air ~ % mysql --version
zsh: command not found: mysql

Your shell does not automagically pick up new executables from your $path. For the shell to find the new executable, you will need to

  • rebuild your shell’s command lookup table with
    hash -fr
    
  • restart your shell with
    exec zsh
    
  • or open a new tab in your terminal.
Related