Mac first install MySQL, input mysql-u root-p will appear: Zsh:command not found:mysql prompt. The environment variables need to be configured at this time.
Mac version of MySQL client: mysql-5.6.24-osx10.9-x86_64.dmg
The first thing to know is what kind of shell you use for Mac OS x, using commands
Echo $SHELL
If the output is: CSH or TCSH, then you are using C Shell.
If the output is: bash,sh,zsh, then your use may be a variant of the Bourne shell.
Before Mac OS X 10.2, the default is C Shell.
The default is Bourne Shell after Mac OS X 10.3.
Open terminal, input: cd ~
Will enter the ~ folder
Then type: sudo vim. bash_profile
Enter the root user password to execute. sudo uses the root user to modify the environment variable file.
Enter at the bottom of the document: Export Path=${path}:/usr/local/mysql/bin
Then ESC exits the insert state and enters at the bottom: Wq save to exit.
Input: source. bash_profile
Enter execution, run environment variable.
Then enter MySQL and you can use it.
I found out after the test, the above practice every time you turn off the terminal in the open need to re-source. Bash_profile. So VI ~/.ZSHRC, added here:
Export Path=${path}:/usr/local/mysql/bin
After saving source ~/.ZSHRC
Then you can do it once and for all.
Mac system MySQL Configuration environment variable (RPM)