I downloaded the mysql dmg file and went through the wizard to run. Done. I have also started mysql server under system preferences.
The purpose of me doing this is to w
In MacOS, Mysql's executable file is located in /usr/local/mysql/bin/mysql
and you can easily login to it with the following command:
/usr/local/mysql/bin/mysql -u USERNAME -p
But this is a very long command and very boring, so you can add mysql path to Os's Environment variable and access to it much easier.
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
For macOS Mojave
and earlier
Although you can always switch to zsh
, bash
is the default shell in macOS Mojave and earlier and with bash
you have to update .bash_profile
file.
echo 'export PATH="$PATH:/usr/local/mysql/bin"' >> ~/.bash_profile
source ~/.bash_profile
mysql -u USERNAME -p