Deployment steps:1. Download the installation package Https://www.mongodb.org/dl/linuxI chose it. 2. TAR-XZVF linux/mongodb-linux-x86_64-latest.tgz3. RenamingMV Mongodb-linux-x86_64-4.1.0-266-gc7451c0e11 MongoDB4. Create a folder (in the MongoDB
1. Start MongoDB service without access controlsudo service Mongod start2. Connect to an instanceMONGO--port 27017Specify additional command-line options to connect the MONGO shell to the deployment MongoDB server, such as--host3. Created User
Upload mongodb-linux-x86_64-2.4.9.tgz to App server directory:/USR/LOCAL/SRC (use the software package plus the bottom of the list for free)Unzip MongoDB#cd/USR/LOCAL/SRC#tar-ZXVF mongodb-linux-x86_64-2.4.9.tgzMobile MongoDB Directory#mv
MongoDB provides a 64-bit installation package for each Linux distribution, and you can download the installation package on the website. : https://www.mongodb.com/download-center#communityDownload the installation package and unziptgz(The following
Create a databaseThe syntax format for MongoDB database creation is as follows:use DATABASE_NAMEIf the database does not exist, create the database, or switch to the specified database.If you want to see all the databases, you can use the show DBS
MongoDB uses the Bson format to store data records. Such as:Document structureThe document consists of a key-value pair with the following structure:
{Field1:value1,Field2:value2,...Fieldn:valuen}?
The value of the field can be any
Since the MongoDB storage time is stored in UTC time, its official drive mongodb.driver the time to save the local time to UTC time, but it has an egg-sore bug, and when read it is very painful to return UTC to make the time. A very intuitive
MongoDB Create Collection1. Manually Create:Syntax format:DB. CreateCollection(name, options) Parameter description:
Name: The collection name to create
Options: Optional parameters, specifying option for memory size and index
The last chapter is over MongoDB installation and IDE tools, now start using Java to connect.The first step: using the jar package,Here need three packages, specifically why I do not know, anyway, because of the error, I have to follow the official
First, prefaceThe date type in MongoDB is no time zone concept, the default storage is Isodate ("2018-04-02t13:19:16.418z") This format of 0 time zone, eight hours later than Beijing time.There is a problem in the work, how to query the document
Replica setAuthority authenticationA keyfile file is to be used for authentication of permissions between nodes.
Mkdir-p/mnt/mongodb/rs/config
Cd/mnt/mongodb/rs/config
OpenSSL rand-base64 741 > Mongodb-keyfile
chmod
Query based on the length of a field (title) in the collectionDb.collections. Find true " This.title.length " })// Note that kanji is not a character
Refresh the config information for the MONGOs cacheDb.admincommand ({"flushrouterconfig":1})//
On the left is the MONGODB query statement, and the right is the SQL statement. Compared with the use, very convenient.
Db.users.find () SELECT * from Users
Db.users.find ({"age": + }) select * from the users where age =
Db.users.find
The data structure of the document is basically the same as JSON.All data stored in the collection is in the Bson format.Bson is a binary form of a class JSON storage format, referred to as binary JSON.Insert DocumentMongoDB uses the Insert () or
Basic operation of MongoDBEnter MONGO into the database in CMD. Enter show databases can query the existing database, admin and local are the own database, notTo operate these two databases. The following is the basic operation of MongoDB: additions
MongoDB Concept AnalysisNo matter what database we learn, we should learn the basic concepts, the basic concept in MongoDB is a document, a collection, a database, we introduce each one.The following table will help you understand some of the
Document Query
Command
Operation
db.mycoll.find(key:value)
Data for query condition
db.mycoll.find(...).count()
Querying and Counting
db.mycoll.find(...).limit(n)
MongoDB's replication set has the function of automatically tolerating partial node downtime, which triggers an election-related process when the replication set is in trouble, and automatically switches the master-slave node.Each replica set member
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.