'MySQL command is not found in M1 Mac

as titled, my question is in my m1 Mac terminal, after successfully installing MySQL from the official page, I enter the mysql command, but it returns command not found.

I googled alot, and this is one of the solution i found:mysql command is not found in macOS

Per the instruction of the page, I found my path to my mysql already, it's /usr/local/mysql-8.0.27-macos11-arm64/bin, I am now in my zshrc too, but i don't know how to put export PATH=$PATH:/usr/local/<my-path>/bin in to zshrc.

While there are so many lines of different settings in it, how do i specify this path is for mysql? and where to put?

Thank you guys



Solution 1:[1]

Since PATH is already exported (try a printenv PATH to see), you don't need to export it, but only extend it.

Hence, you can do in your .zshrc a

path+=/usr/local/mysql-8.0.27-macos11-arm64/bin

BTW, I would also do a

typeset -aU path

(if it is not there already), to ensure that you don't have duplicate entries in your PATH/path.

Solution 2:[2]

If not you using homebrew and have a manual installation of mysql:

vi ~/.zshrc
export PATH=${PATH}:/usr/local/mysql-8.0.28-macos11-x86_64/bin/
source ~/.zshrc

note: replace /mysql-8.0.28-maos11-x86_64/ with whichever version of mysql is installed.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user1934428
Solution 2 zach