0

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

EntzY
  • 467
  • 4
  • 11

2 Answers2

3

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.

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
zach
  • 25
  • 2
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.

user1934428
  • 19,864
  • 7
  • 42
  • 87
  • Thank you for your answer. Does this "typeset -aU path" has to be in the front of, or behind the "path+=/usr/local/mysql-8.0.27-macos11-arm64/bin" ? – EntzY Nov 09 '21 at 20:54
  • Thank you very much for the answer, but when i tried "mysql -u root -p", it still returns "zsh: command not found: mysql" – EntzY Nov 09 '21 at 21:09
  • @EnzoY : AFIK, the position of the `typeset` does not matter, but the PATH is of course not cleaned for duplicates until zsh encounters this declaration. – user1934428 Nov 10 '21 at 07:25
  • @EnzoY : If it does not work, it means that your path statement has not been processed. Check the PATH and post it here. You can create a new zsh subshell with `zsh -x` and analyze the trace to see what's going on. – user1934428 Nov 10 '21 at 07:27