Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install MongoDB database

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is about how to install the MongoDB database. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

1. Download the mongodb system package

Wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.4.tgz

two。 Decompress the package

Tar-zxvf mongodb-linux-x86_64-rhel70-3.2.4.tgz

3. Rename the decompression package to mongodb under / usr/local/

Mv mongodb-linux-x86_64-rhel70-3.2.4 / usr/local/mongodb

4. Create a database directory

Cd / usr/local/mangodb/bin

Mkdir-p data/test/db

Mkdir-p data/test/logs

5. Create a profile mongodb.conf

Vi mongodb.conf

Dbpath = / usr/local/mongodb/bin/data/test/db

Logpath = / usr/local/mongodb/bin/data/test/logs/mongodb.log

Port = 27017

Fork = true

Nohttpinterface = true

6. Start mongodb

. / mongod-f mongodb.conf

7. View the mongodb process:

Ps-ef | grep mongodb

[root@localhost ~] # wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.4.tgz

-- 2018-08-26 18 1714 12 muri-https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.4.tgz

Resolving fastdl.mongodb.org (fastdl.mongodb.org)... 54.230.249.222, 54.230.249.122, 54.230.249.63,...

Connecting to fastdl.mongodb.org (fastdl.mongodb.org) | 54.230.249.222 |: 443. Connected.

HTTP request sent, awaiting response... 200 OK

Length: 63674272 (61m) [application/x-gzip]

Saving to: 'mongodb-linux-x86_64-rhel70-3.2.4.tgz'

63674272 3.36MB/s in 31s

2018-08-26 18:17:45 (1.93 MB/s)-'mongodb-linux-x86_64-rhel70-3.2.4.tgz' saved [63674272 ash 63674272]

[root@localhost] # tar-zxvf mongodb-linux-x86_64-rhel70-3.2.4.tgz

[root@localhost] # mv mongodb-linux-x86_64-rhel70-3.2.4 / usr/local/mongodb

[root@localhost mongodb] # cd bin

[root@localhost bin] # mkdir-p data/test/db

[root@localhost bin] # mkdir-p data/test/logs

[root@localhost bin] # vi mongodb.conf

Dbpath = / usr/local/mongodb/bin/data/test/db

Logpath = / usr/local/mongodb/bin/data/test/logs/mongodb.log

Port = 27017

Fork = true

Nohttpinterface = true

[root@localhost bin] #. / mongod-f mongodb.conf

About to fork child process, waiting until server is ready for connections.

Forked process: 11487

Child process started successfully, parent exiting

[root@localhost bin] #. / mongo

> use DATABASE_NAME

If the database does not exist, create the database, otherwise switch to the specified database.

> use kingscc

Switched to db laoA

> show dbs (check what databases are available. Databases without data are not displayed)

Local 0.000GB

Db (displays the current database)

Kingscc

> db.laoA.insert ({"name": "kingscc,"}) (insert data into the database)

WriteResult ({"nInserted": 1})

> db.dropDatabase () (use the database first, then delete it)

Delete the current database. The default is test. You can use the db command to view the current database name.

Thank you for reading! This is the end of this article on "how to install MongoDB database". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report