Mac Terminal Issue – New Terminal Can’t Find File Using ‘which’

MySQLterminal

After I installed the mysql in my Mac, it locate in the:

/usr/local/mysql 

And after I use export add the PATH to the $PATH, I can use which mysql_config find it:

aircraftdeMacBook-Pro:/ ldl$ which mysql_config
/usr/local/mysql/bin//mysql_config

But however when I use Command+N create a new Terminal, in it can not searched the mysql_config now:

enter image description here

Best Answer

If you modify the PATH variable in a Terminal session by exporting it (e.g. export PATH="/usr/local/mysql/bin:$PATH" it will be expired in the next session.

So either edit the file ~/.bash_profile or edit /private/etc/paths if you need this PATH for other users also.

In ~/.bash_profile add the line:

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

In /private/etc/paths add the line

/usr/local/mysql/bin

Close your current Terminal session, launch a new one to enable the new PATH and check the result:

echo $PATH
which mysql_config