I have installed MySQL with .dmg installation file according to the official page. But it returns command not found: mysql when I execute mysql command.
How to fix this issue?
I have installed MySQL with .dmg installation file according to the official page. But it returns command not found: mysql when I execute mysql command.
How to fix this issue?
The documentation for MySQL says:
When installing using the package installer, the files are installed into a directory within /usr/local matching the name of the installation version and platform. For example, the installer file mysql-5.7.29-osx10.13-x86_64.dmg installs MySQL into /usr/local/mysql-5.7.29-osx10.13-x86_64/.
Once you verify that there is a bin folder in this directory, you have to make sure that the terminal looks for the MySQL command there. This can be done by executing the following command:
export PATH=$PATH:/usr/local/<my-path>/bin
If you had installed [email protected] using brew:
paste/type below command in terminal:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
then paste/type:
mysql -u root
boom!!!!
reason: brew files are installed in usr/local/opt
Try this if you have not upgraded your OS and wants to access mysql
instead of -> mysql -u root -p
use -> /usr/local/mysql/bin/mysql -u root -p
mysql instead of the full path for easy of usemysql, edit your shell profile, if you're using Bash, this file is usually either ~/.bash_profile, ~/.bashrc, or ~/.profile. If you're using Zsh, it's likely ~/.zshrc. Add this line: export PATH="/usr/local/mysql/bin:$PATH", restart the terminal and try mysql -u root -p