MySQL from OSX Terminal
I had this kind of problem as well. I resolved the issues like:-
- go to the directory cd /usr/local/mysql/bin/
- put this command ./mysql -u root -p;
- it will ask you password the root password you get at the time of installation. that way you will get your mysql connected to the database... hope that helps..
/usr/local/mysql/bin
is not in the default $PATH
. $PATH
is the list of directories that are searched when you try to use an executable without specifying a complete path.
You either need to use the full path (/usr/local/mysql/bin/mysql_executable_here
) or add it to your $PATH
:
export PATH="$PATH:/usr/local/mysql/bin"
For macOS Mojave and earlier
You can add this line to a file called .profile
in your home directory to execute it each time you create a new shell:
echo 'export PATH="$PATH:/usr/local/mysql/bin"' >> ~/.profile
source ~/.profile
mysql -u USERNAME -p
For macOS Catalina and later
Starting with macOS Catalina
, Mac devices use zsh
as the default login shell and interactive shell and you have to update .zprofile
file in your home directory.
echo 'export PATH="$PATH:/usr/local/mysql/bin"' >> ~/.zprofile
source ~/.zprofile
mysql -u USERNAME -p