MongoDB Configuration and PHP connectivity test(2010-05-10 10:41:36) reprint
Tags: mongodb php topics
Category: Technical Articles
The auto-sharding function of MongoDB refers to the mongodb of a horizontally expanding
MySQL users have most of the auto increment complex, but MongoDB default is not implemented, so need to simulate, programming language in PHP for example, the code is as follows:
1,
' Step ' => 1,
);
$instance = new Mongo ();
Turn from: http://www.chengxuyuans.com/syskills/Windows7/66110.html
1. Python Installation
Download: http://python.org/download/
Double-click the installation and add the path to the system environment variable path after installation.
2. MongoDB
First need to install Pymongo module, module download address
https://pypi.python.org/pypi/pymongo/#downloads
Select the appropriate version, to install, after the installation is completed, you can link your mongodb.
pymongodb-2.3.tar.gz Download:
First, the application scene: Find MongoDB news name is not "", also not NULL news name, and according to the Heat rankings:
$map [' title '] = Array (' $not ' =>array (' $in ' =>array ("", null));
$news = $this->where ($map)->order (' Value desc ')-
Failure Phenomenon
MongoDB After the restart, waited for several 10 minutes still did not start completion, single node replica set, the state has been in startup reason analysis
View Mongod error log, found to have been in building index, but
Http://www.mongodb.org/downloads website Download address can be down to the latest MongoDB.
There is a full English installation instructions above.
Here a brief introduction, supply to see E-wen headache students.
There are two ways to start after
Start Configsvr
1. Ensure that the configsvr of the MONGDB is started in service mode, that is, from the script under/ETC/INIT.D, and that the user is mongod.
2. Ensure that the Mongod configuration files are identical.
3. Ensure that all keyfile
OK, continue to complete the second demand, to find the number of records in a day statistics, directly run the "Combat 4" prepared MapReduce, the exception is not a number Nan, through the analysis of the results, found the reason, the reason
Today, when configuring MongoDB, Win10 encountered a small problem, the configuration for the service is always not configured, the results found that the following command is not running as an administrator, resulting in failure.
Gridfs is a file specification for storing large files in MongoDB:The MongoDB database holds binary objects in support of the Bson format , but the Bson objects in MongoDB cannot exceed 4MB in maximum.The GRIDFS specification provides a transparent
The primary key is set by the comment "@Id", and MongoDB automatically generates the primary key if the primary key is not set.
Import Org.springframework.data.annotation.Id;
public static class ordercomsumedto{
@Id
private String OrderNo;
The MongoDB remove () function is used to remove data from the collection.
The update () function can be used for MONGODB data updates. It is a good practice to execute the Find () command before executing the Remove () function to determine if the
MongoDB implementation file deletion
Do Itoo in the process, in the implementation of the MongoDB file deletion when encountering point problems, Internet search, many online resources, want to find out what they want is not easy, so can only try,
After the successful start of MongoDB, and then open a command line window input MONGO, you can do some of the database operations. Enter help to see the basic Operations Command, but MongoDB does not create a database command, but there are similar
One, insufficient authority
We have two workarounds for this.
1,# setcap Cap_fowner+ep/usr/bin/mongod
2,chmod +777 MONGO
Two,
The reason for this problem is that there is no proper operation when exiting.
Workaround:
1. Find the file
Http://www.07net01.com/2016/11/1722629.html
This article describes the content of MongoDB remote access configuration, the following words do not say, directly to see the detailed steps.
1, first modify the MongoDB configuration file to listen to
MongoDB Getting Started column
Http://blog.csdn.net/column/details/19681.html
Database Operations View Database
# View all databases under the current MONGO
> Show Databases
> Show DBS
Create a database
# Connect, create TestDB database
> Use
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