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

Setting up MongoDB installation environment

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Default port number 27017 for Mongodb

_ id is the global unique value. Do not assign a value to this column. By default, it is unique. If you assign a value and include the _ id:2 with two columns, the conflict will be reported and cannot be inserted.

[root@HE4 ~] # tar xvf mongodb-linux-x86_64-2.6.10.tgz

[root@HE4] # mkdir-p / export/mongodb

[root@HE4] # mkdir-p / export/mongodb/bin

[root@HE4] # mkdir-p / export/mongodb/conf

[root@HE4] # mkdir-p / export/mongodb/log

[root@HE4~] # mkdir-p / export/mongodb/data

[root@HE4bin] # cd / root/mongodb-linux-x86_64-2.6.10/bin

[root@HE4bin] # cp / root/mongodb-linux-x86_64-2.6.10 Candle * / export/mongodb/bin/

[root@HE4conf] # vi / export/mongodb/conf/mongod.conf

[root@HE4conf] # cat mongod.conf

Port=27408

Dbpath=/export/mongodb/data

Logpath=/export/mongodb/log/mongod.log

Fork=true

[root@HE4bin] # cd / export/mongodb/bin

[root@HE4bin] #. / mongod-f / export/mongodb/conf/mongod.conf

[root@HE4bin] # / mongo-- port 20011

>

>

> showdbs

Admin (empty)

Local 0.078GB

> useadmin

Switchedto db admin

> db.shutdownServer ()

[root@HE4bin] # netstat-anlp | grep mongod

[root@HE4bin] # / mongo-- port 20011

> usehelei

Switchedto db helei

> db.t1.insert ({id:1})

WriteResult ({"nInserted": 1})

> db.t1.insert ({id:2})

WriteResult ({"nInserted": 1})

> db.t1.find ()

{"_ id": ObjectId ("57033a5eade0255b255b4e22"), "id": 1}

{"_ id": ObjectId ("57033a6bade0255b255b4e23"), "id": 2}

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