In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
What is Mongodb ?
Mongo DB is an open source, non-relational database (NoSql) with a flexible document model that allows you to develop smoothly. For Internet applications with large data volume, high concurrency and weak transactions, MongoDB can handle it freely. MongoDB's built-in horizontal scaling mechanism provides data processing capabilities ranging from millions to billions, which can fully meet the data storage needs of Web2.0 and mobile Internet. Its out-of-the-box features also greatly reduce the O & M costs of small and medium-sized websites.
install MongoDB
Go to mongodb official website http://www.mongodb.org/You can find the YUM source here and install two packages corresponding to the version, one for the server and one for the client. The package name is as follows:
mongo-10gen-2.4.12-mongodb_1.x86_64.rpm
mongo-10gen-server-2.4.12-mongodb_1.x86_64.rpm
Add official yum source:
vim /etc/yum.repos.d/monogdb.repo
[mongodb]name=MongoDB Repositorybaseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/gpgcheck=0enabled=1
yum install mongo-10gen.x86_64 mongo-10gen-server.x86_64 -y
Create mongodb data folder
mkdir /mongodb/data/
chown -R mongod.mongod /mongodb/data/
Modify the configuration file/etc/mongod.conf to specify the data directory
dbpath=/mongodb/data
Start Mongodb
service mongod start
CRUD operation of Mongodb
[root@server1 ~]# mongo
MongoDB shell version: 2.4.5
connecting to: test
> show dbs //Show database
local0.078125GB
testdb0.203125GB
> use testdb //Use the database without creating it in advance.
switched to db testdb
> db.testmcoll.insert({Name: "Jerry"}) //Specify collection insert data
> db.testmcoll.insert({Name:"Haiman"})
> show collections //Show collections in the library
system.indexes
testmcoll
> db.testmcoll.find() //Find data in a collection
{ "_id" : ObjectId("549fcaa56e8223a06e8b1f52"), "Name" : "Jerry" }
{ "_id" : ObjectId("549fcadc6e8223a06e8b1f53"), "Name" : "Haiman" }
> db.testmcoll.stats() //Output status information for the collection
{
"ns" : "testdb.testmcoll",
"count" : 2,
"size" : 80,
"avgObjSize" : 40,
"storageSize" : 4096,
"numExtents" : 1,
"nindexes" : 1,
"lastExtentSize" : 4096,
"paddingFactor" : 1,
"systemFlags" : 1,
"userFlags" : 0,
"totalIndexSize" : 8176,
"indexSizes" : {
"_id_" : 8176
},
"ok" : 1
}
>
> db.testmcoll.drop() //Delete collection
true
Multivalued insertion and bulk insertion
db.users.insert( { name:"Tom", age:23, status:"S", groups:[ "News","concert" ] } )
for(i=1;im.txt
Summary complete!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.