1

I want to add the PATH for mysql.exe on my Mac. I tried this via terminal, but

$ vi.bash_profile
vi.bash_profile command not found.

does not work. I tried this for generating the bash_profile to add the PATH.

We want to enter the code

export PATH=PATH:/Machintosh HD/Application/mampstack-7.3.8-0/mysql/bin

after the generating bash_profile.

4

You need a space after vi and before the . so vi .bash_profile not vi.bash_profile.

If you are not in your home folder you can also use vi ~/.bash_profile to specify the location as mentioned in ankiis answer below/above. Again you need a space after the vi.

Alternatively, instead of using vi you can add your path to .bash_profileusing echo 'export PATH=/my/path:$PATH' >> ~/.bash_profile as explained in this answer.

|improve this answer|||||
  • In fact it's: echo 'export PATH=$PATH:/my/path' >> ~/.bash_profile in this case (PATH=global_PATH:/custom_bin) and echo 'export PATH=$PATH:/Applications/mampstack-7.3.8-0/mysql/bin' >> ~/.bash_profile in this special case. – klanomath Nov 13 '19 at 13:01
2

Bash profile can be reached at ~/.bash_profile. I don't use vim, but nano ~/.bash_profile works. Hope vim is similar too.

|improve this answer|||||
1

Some users who are new to the Mac will find it easier to edit their bash_profile file directly in their favourite text editor rather than via Terminal. Yes, it's slower, but can be easier for newbies to understand what's going on and diagnose errors. Here are the steps.

  1. Open Finder and from the menu at the top select Go → Home.

  2. Sort the files in your Home directory by name alphabetically, then look for a file called ".bash_profile". The file will be greyed out. (If you can't see any greyed-out files, toggle showing hidden files with shift-cmd-.)

  3. Duplicate the file to make a backup. (I suggest renaming the duplicate with today's date - e.g. ".bash_profile_BAK_20191005".)

  4. Open the .bash_profile file with your favourite text editor - e.g. Sublime Text.

  5. Read through the file! (I learned most about how the .bash_profile works by Googling every line and then editing it with ideas suggested by other Stack Exchange users.)

  6. Add the new line you need (making sure - using Finder or Terminal - that the path you are adding actually points to the right files on your own Mac, which may of course be different to other users).

  7. Save the file.

  8. Reload the new bash profile by going into Terminal and running the following line:

    source ~/.bash_profile

Re point 2 above, I installed MySQL via Homebrew, and the paths were different to yours (and are different again on my other Macs). E.g. my current paths to MySQL are:

export PATH=/usr/local/Cellar/mysql/8.0.12:$PATH
export PATH=/usr/local/Cellar/mysql/5.7.22/bin/mysqld:$PATH

Ultimately the two options - edited in Vim in Terminal or in a text editor - end up at the same destination. The only thing that matters is which approach you personally find easier.

|improve this answer|||||
  • 3
    In Finder, CMD + shift + . can be used for hidden files. pressing them toggles the visibility. – ankii Oct 5 '19 at 15:15

You must log in to answer this question.

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