At development time, the general data test is in the test environment, this is the need to set the host to point to the test database; Below I recorded three methods, also seen on the Internet, take notes here.
1. Edit Host via VI
Here's how:
(a) Open the terminal and enter the following command:
sudo vi/etc/hosts
(b) Enter the password (login to the computer password)
(c) Some data will be displayed at the terminal, about host introduction, and if the last line is displayed as more, press ENTER to see some editing commands;
respectively: Open edit recover Delete quit;
Enter E, enter the editor, enter the edit interface, input I to insert, after the insertion, press ESC, and then enter: Wq to save;
2. Edit host via Nano
The method is similar to the above and runs in the terminal:
sudo nano/etc/hosts
The same is to enter the password, open the Hosts file, according to your needs to edit the file, after editing, press Ctrl+o save, the file Name to Write:/etc/hosts, press ENTER to confirm, and then press Ctrl+x exit.
3. Modify in the graphical interface
Open the Finder, and then click on the menu bar to go-to the folder (or shortcut shift+command+g), enter/private in the path, after entering the ETC folder right-click-Show Introduction, in the folder Introduction window at the bottom of the "Share and Permissions", Change the permissions of everyone to read and write, and if you find that you cannot modify it, you can modify it by unlocking the small lock in the lower right corner.
After modifying the permissions of the ETC folder, then enter the ETC folder, modify the permissions named Hosts file (same as everyone read and write), after the modification, you can directly in the Hosts file right-click, through the "text edit" to open and edit the file, No prompt will appear without permission. After modifying and saving, remember to restore the file and the permissions of the ETC folder.
The next three ways I have verified, in the latest system can be used!
Host setting method in Mac