Install MongoDB and visualization tools under Mac and solve problems during the installation process

One, install MongoDB

1. Download address

Official website download address: https://www.mongodb.com/download-center/community

Insert picture description here

2. Download and install

Click the [Download] button, put the decompressed mongodb-osx-x86_64-4.0.10 file into /usr/local, and name the file MongoDB (by default, the /usr directory is not visible in the Finder , You can open the Finder and press command + space to enter /usr/local and press Enter to see this directory).

Insert picture description here

Insert picture description here
Insert picture description here

3. Configure system environment variables

Open the terminal, type open -e .bash_profile, type in the opened file export PATH=${PATH}:/usr/local/MongoDB/bin, save and close the .bash_profile file.

Insert picture description here

4. Check if the installation is successful

Then enter "source .bash_profile" in the terminal and press Enter to make the configuration effective, then enter "mongod -version", and then press Enter. If you see the version number below, it means that MongoDB has been installed successfully.

Insert picture description here

5. Create a MongoDB data repository

Enter in the terminal sudo mkdir -p /data/db, create a new data folder, and create a db folder inside

Insert picture description here

Second, run MongoDB and solutions to problems during installation

1. Start the mongodb server

Open the terminal input mongod(note the input mongod, not mongodb) start the mongodb server

1.1. If the situation as shown in the figure below appears, the startup is successful!

Insert picture description here

1.2. (If the startup is successful in step 1.1, you can ignore this step) If an error is reported as shown in the figure below, it means that the startup is not successful:

Insert picture description here
Solution

Shown above was created / data / db has only read, not write permission, so give db add this folder permissions,
and then navigate to the data directory, execute sudo chmod 777 dbto the db set to a highest authority, or execute sudo chown Your username is /data/db.
Insert picture description here
Then execute mongod again to successfully open the server.
Insert picture description here

2. Check whether the link server is successful

Open the browser, enter localhost:27017 in the address bar, and the situation as shown in the figure below appears, which means that the connection to the server is successful.

Insert picture description here

Three, install MongoDB visualization tool

1. Download

Download link: https://www.mongodb.com/download-center/compass

Insert picture description here

2. Install and link MongoDB database

Click [Download] to download and install, then click [CONNECT]

Insert picture description here

As shown in the figure below, it means that the connection to the database is successful.
Insert picture description here

If the situation shown in the figure below appears, it means that the MongoDB server is not started, and you need to enter it in the terminal to mongodstart the MongoDB server.

Insert picture description here

Guess you like

Origin blog.csdn.net/it_cgq/article/details/94762335