Search code examples
macoscommandbashiterm2path-variables

Cant access my bash files


So I wanted to install MySQL on my MBP and I edited my bash_profile, added a path variable, however when I run echo $PATH from iTerm2 I get my path as:

Robs-MBP:~ Rob$ echo $PATH /usr/local/mysql/bin

Ive tried a lot of commands and even used sudo and it just says command not found. My fear is that I have completely messed up, and now nothing works. Please help.


Solution

  • You've made a simple mistake: all you've done is reset the PATH env variable. To correctly do this, you should always add the existing PATH to the end of whatever you're adding. In you case:

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

    To fix your problem from the terminal, you'll need to reset your PATH to somewhere with a text editor. I don't know where this is located on OSX, so you'll have to find it. After you know where your path should point, run:

    $ export PATH=<YOUR_PATH_HERE>

    Then edit your bashrc to include the original path as described above, and restart the terminal.

    Alternatively, open .bashrc with a GUI text editor and make the change from there. Your PATH decleration should always end in :$PATH to include the PATH created by your system.