After installation, enter in the console:
MONGO start the client.
Show DBS displays all databases.
Use XXX to select the database for the current database.
Show collections displays all collections of the current database.
Db.colleciton.find ()
Common JavaScript statements
Copy Code code as follows:
Db.getsiblingdb ()
Db.getcollectionnames ()
Db.getcollection ()
Db.printcollectionstats ()
Running JavaScript scripts on the MONGO shell
To switch a database:
0x00 MongoDB Permissions Introduction
1.MongoDB installation does not add any parameters, the default is not permission to authenticate, the user can log on to the database any operation and remote access to the database, you need to start with the-
One of the biggest features of MongoDB is that it supports dynamic queries, just like traditional relational database queries, but its queries come in more flexible mode.
One, query Expression Objects: Querying an Expression object
The query
We know that MySQL in the installation of the need for us to set a database default username and password, MongoDB is no exception, but MongoDB is the default does not set access restrictions, do not need to enter a username and password can be
One, find operation
Find is used in MongoDB to query, and all and part of the query can be implemented by specifying the first parameter of find.
1, all inquiries
The empty query document {} will match the entire contents of the collection. If
Background
Recently I was writing a test kit with a bug-recording system, because I was using Django and MongoDB in the background, and I ran into a problem with how to implement a self added field.
The traditional relational database is very easy
Increase Arbiter
Add the profile mongod1,mongod2,mongod3 to the arbiter of Shard1,shard2,shard3 three set sets, respectively.
Copy Code code as follows:
Replset=shard1
Replset=shard2
Replset=shard3
Start the Mongod
MongoDB default set to No access restriction note: Research results based on Windows platform
After successfully deploying MongoDB, enter the console: \ Input command: Mongod use admin, You will find that the DB contains a system.user table, hehe,
MongoDB log files in the case of setting logappend=true, will continue to the same log file appended, the time is long, naturally become very large.
Resolved as follows: (Special note: The boot must be--logpath specified log path)
Connecting to
Step1:
Download Https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.11.tgz The latest version, this is the linux64 bit download address, you can also go to the homepage of their own choice
Step2:
Extract the Tar vxf mongodb-linux-x86_64-2.4.
In the next chapter, this article mainly said, MongoDB group function, do or quite powerful, quite for find (), skip (), distinct (), etc., the use of more complex.
Test data:
Copy Code code as follows:
> Db.fruit.find ();
{"_id": 1
We look at MongoDB from an administrator's point of view, as an administrator, we are often exposed to 4 main areas:
1. Install deployment
2. State Monitoring
3. Security certification
4. Backup and Recovery,
Here we will explain the 1.1 points.
There is another cluster in the MongoDB, the partitioning technology, similar to the table partitioning of SQL Server, we know that when the amount of data reaches the T level, our disk, memory is too high, how to deal with such a scenario how we
These days the project revision, the time is comparatively tight, the blog also did not keep abreast, also hoped everybody forgive me.
Well, today sharing the basic operation of the index in the MongoDB, we do not avoid the day-to-day development
1. Create a Super User
Use admin
db.createuser (
{
User: "Adminusername",
pwd: "UserPassword",
roles:
[
{
roles: "Useradminanydatabase",
DB: "admin"
}
)
There are two types of superuser
The MongoDB database foreach statement circular traversal function is a very common function.A foreach loop is used to iterate, and the callback function is allowed to execute once per loop.In addition, the Foreach Loop traversal is an extension of
Insert () Method:The following is a document that inserts a three field into the inventory collection:
Copy Code code as follows:
Db.inventory.insert ({_id:10, type: "Misc", Item: "Card", qty:15})
In the real example, the document
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.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service