Installation method of MongoDB database and related PHP extensions
Installation method of MongoDB database and related PHP extensions
1. Installation and use of MongoDB 1. Download MongoDB: Download the corresponding mongodb according to your operating system version, mine is ubuntu64, so download this in /opt/: http://fastdl.mongodb.org/linux /mongodb-linux-x86_64-2.0.3.tgz 2. Unzip: tar zxvf /opt/mongodb-linux-x86_64-2.0.3.tgz 3. Manually create the data and log storage path of mongodb The default path of mongodb is /data/db/, my settings: /opt/data/mongodb/data/ and /opt/data/mongodb/log/ 4. Start mongodb: /opt/mongodb-linux-x86_64-2.0.3/bin/mongod –dbpath /opt/data/mongodb/data/ –logpath /opt/data/mongodb/log/m1.log –journal –fork To start mongodb automatically when linux starts, vi /etc/rc.local Add the above sentence 5. Operate mongodb through shell commands the /opt//mongodb-linux-x86_64-2.0.3/bin/mongo > use my_mongodb // If there is no my_mongodb, it will be created automatically This is equivalent to the database switched to db my_mongodb > db.user.insert({uid:1,username:”Tom”,age:25}); //If there is no user collection, automatically create and insert a piece of data, which is equivalent to writing a document to a collection > db.user.insert({uid:2,username:”Jerry”,age:25}); the > In this example, 2 records are inserted into the table user of the database my_mongodb. MongoDB will implicitly create the database my_mongodb and table user, so this example does not have the process of building a database and table, you can use show dbs and show collections to view databases and tables, as follows: > show dbs…