3

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

  • Add this export $PATH to the ~/.bash_profile file. This file is "executed" every time new Terminal window/tab is opened. – Mateusz Szlosek Jun 21 '17 at 9:45
3

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
  • If there is diffrence between export PATH="/usr/local/mysql/bin:$PATH" and export PATH="$PATH:/usr/local/mysql/bin" – aircraft Jun 21 '17 at 9:54
  • @aircraft The first occurrence of a file x in the path will be executed or found with which. If you would have an old version of mysql_config in e.g /usr/bin it would be executed in the second case but not your new mysql_config. It's the other way round in the first case: the file mysql_config in /usr/local/mysql/bin/ would be executed preferably and the file /usr/bin/mysql_config would be ignored. – klanomath Jun 21 '17 at 10:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .