Three ways to add environment variables for Mac
Method 1: system level, modify/etc/paths (each row is an environmental variable)
Method 2: system level for convenient management
1. Create a file:
Sudo touch/etc/paths. d/MySQL
2. open the file with vim (if it is opened in Open-T mode, it cannot be edited ):
Sudo Vim/etc/paths. d/MySQL
3. edit the file, type the path, and save it. (close the terminal window and open another one. You can use the MySQL Command)
/Usr/local/MySQL/bin
It is said that this allows you to generate new files by yourself without storing all the variables in a paths file for convenient management.
Method 3: user-level
1. Create ~ /. Bash_profile File
2. Added environment variables.
Export Path = "$ home/. rbenv/bin: $ path"
3. Make the above configurations take effect
Source ~ /. Bash_profile
4. Check whether the setting takes effect. (You may need to close the current terminal window to enable another setting)
Echo $ path
Note that the colon is the separator of the environment variable ):
$ Home/. rbenv/bin: $ PATH specifies/usr/bin:/usr/sbin:/usr/local/bin
If you want to add multiple environment variables, you need to write them as follows:
Export Path = "$ path:/applications/MacVim-snapshot-68"
Export Path = "$ home/. rbenv/bin: $ path"
Eval "$ (rbenv init -)"
Export Path = "$ home/. rbenv/bin: $ path"
Eval "$ (rbenv init -)"
Three ways to add environment variables for Mac