How to add MySQL to $PATH variable to resolve "mysql: command not found"?

Here is why your current code is not working:

export PATH=${PATH}/usr/local/mysql/bin/

You forgot the colon and the trailing "/" is unnecessary.

export PATH=${PATH}:/usr/local/mysql/bin

is the correct code.


Try adding the following line to your .bash_profile file.

export PATH="/usr/local/mysql/bin:$PATH"

You can do this easily with the following command, which will append the line if the file already exists or create a new file with the line if it doesn't.

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

You can accomplish this by going to your .bash_profile file and adding these lines to it.

alias mysql.start="sudo /usr/local/mysql/support-files/mysql.server start"
alias mysql.stop="sudo /usr/local/mysql/support-files/mysql.server stop"
alias mysql.restart="sudo /usr/local/mysql/support-files/mysql.server restart"
alias mysql.status="sudo /usr/local/mysql/support-files/mysql.server status"

After you've done this you can start, stop, restart and check the status of your connection anywhere in your terminal like this:

mysql.start - starts mysql
mysql.stop - stop mysql
mysql.restart - restarts mysql
mysql.status - checks the status of mysql

Hope that helps even tho I might be late. CHEERS!