How to solve zsh permission denied when adding MySQL to path?

4.4k Views Asked by At

I'm trying to add mysql to path so that SQL commands interact with a MySQL database, however, permission denied. How do you solve this problem?

For macOS Catalina 10.15.6

To find MySQL Location

/usr/local/mysql/bin

This returns error

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

Solution to zsh permission denied by specifying ~/.zshrc

To add MySQL to Path (permanently)

echo 'export PATH="/usr/local/mysql/bin:$PATH"' >> ~/.zshrc

This returns

source ~/.zshrc

Set root user password for mysql login

mysql -u root -p

This returns error

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

*Started MySQL Server to connect with "root" user password

sudo /usr/local/mysql/support-files/mysql.server start

Enabled MySQL prompt

Welcome to the MySQL monitor...
mysql> 
1

There are 1 best solutions below

1
On

First stop mysql if it's running by typing in terminal

/usr/local/mysql/support-files/mysql.server stop

then start mysql by typing

/usr/local/mysql/bin/mysqld_safe

open a new terminal window

/usr/local/mysql/bin/mysql -u root -p 

enter the password and then will run