Three ways to add environment variables for Mac

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.