Three methods for adding environment variables for Mac: sudo vi/etc/paths to edit paths and add environment variables to paths. Vim is an editor with several other features, such as Pico and Emacs. Hint: when entering environment variables, you don't need to input them one by one. You just need to drag the folder to Terminal. Method 2: 1. create a file: sudo touch/etc/paths. d/mysql2. use vim to open this file (if it is open-t, it cannot be edited): sudo vim/etc/paths. d/mysql
3. edit the file, type the path, and save the file (close the Terminal window and open a new one, you can use the mysql Command)/usr/local/mysql/bin is said, in this way, you can generate new files by yourself without storing all the variables in a paths file for convenient management. Method 3: 1. Create and open it as TextEdit ~ /. Bash_profile file touch ~ /. Bash_profile; open-t ~ /. Bash_profile2. added the environment variable export PATH = "$ HOME/. rbenv/bin: $ PATH" 3. Make the preceding configuration take effect. source ~ /. Bash_profile4. check whether it takes effect (sometimes you may need to close the current Terminal window and re-open one) echo $ PATH note (the colon is the separator of the environment variable): $ HOME /. $ PATH in rbenv/bin: $ PATH specifies/usr/bin:/usr/sbin: /usr/local/bin if you want to add multiple environment variables, you need to write 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 -)"