I tried to follow the instructions in How to add MySQL to $PATH variable to resolve "mysql: command not found"?

$ echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.bash_profile
zsh: permission denied: /Users/naveenkumarp/.bash_profile

Can any one help me to solve this issue?

  • 1
    Please run ls -al ~/.bash_profile and copy/paste both the command and the result as text into the question text.
    – nohillside
    Sep 21, 2020 at 11:51
  • 3
    Also, you seem to be running zsh so why do you want to update .bash_profile?
    – nohillside
    Sep 21, 2020 at 11:51
  • I m learning my sql I saw the command use this locate the mysql using the terminal command so I tried this Sep 21, 2020 at 12:06
  • Try change .bash_profile to .zshenv in the command Sep 21, 2020 at 13:14
  • 2
    @ReneLarsen By default, >> will create the file if it doesn't exist, so using > instead is not necessary. And using > is dangerous, because if the file does exist, it'll be silently and irretrievably erased before the new content is added. Sep 21, 2020 at 17:26

2 Answers 2


I would use the nano editor to edit the correct file for your shell, which is zsh, not bash.

nano ~/.zshrc

Put this line in at the top of the file

typeset -U path PATH

Put this line towards the bottom and save:


Press the control key and the X key to exit (see the bottom of the nano window for more commands). If you then quit your terminal app, you can test for mysql being in your path.

You can tell your shell with echo $SHELL and if you want bash since all your instructions are in it, you can go back to that if needed with chsh /bin/bash in which case you would nano the file ~/.bash_profile since each shell reads different start up files. I recommend learning zsh and finding guides that work there, though.

  • 1
    Ahem, the error message says zsh...
    – nohillside
    Sep 21, 2020 at 19:17
  • 1
    Thank you kindly for pointing my error out @nohillside - Do you think .zprofile is better than .zshrc for PATH amends?
    – bmike
    Sep 21, 2020 at 19:31
  • @bmike- add the following line before your path declaration to remove duplicate search paths- typeset -U path or according to the zsh guide- typeset -U path PATH
    – fd0
    Sep 21, 2020 at 19:46
  • I’m not sure of that syntax @fd0 - can you edit my answer if I don’t do it correctly? So much thanks on the help here. I tested my initial answer to be sure it didn’t break horribly
    – bmike
    Sep 21, 2020 at 19:54
  • I have no experience with zsh at all :-)
    – nohillside
    Sep 22, 2020 at 5:36

Change bash_profile to zshenv. Worked for me.

  • 2
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Oct 21, 2021 at 14:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .