First install MongoDB, in the terminal input:
Copy Code code as follows:
sudo apt-get install MongoDB
then start the database MongoDB:
Copy Code code as follows:
This error may occur:
Copy Code code as follows:
Mongod--help for help and startup options
Mongod:symbol lookup error:mongod:undefined Symbol: _zn7pcrecpp2re4initepkcpkns_10re_optionse
install Mongodb-10gen below to resolve this error:
Get download 10-gen public key:
Copy Code code as follows:
sudo apt-key adv--keyserver keyserver.ubuntu.com--recv 7F0CEB10
Create a/etc/apt/sources.list.d/10gen:
Copy Code code as follows:
Echo ' Deb Http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen ' | sudo tee/etc/apt/sources.list.d/10gen.list
Install Mongodb-10gen:
Copy Code code as follows:
sudo apt-get update and then sudo apt-get install Mongodb-10gen
If there is a conflict between the prompt and the remove mongodb-clients, you can uninstall the remove mongodb-clients Reinstall:
Copy Code code as follows:
sudo apt-get remove mongodb-clients
sudo apt-get install Mongodb-10gen
So in the execution of Mongod look at the effect.
Some simple things about MongoDB:
in the terminal input(Mongod must already be started):
Copy Code code as follows:
The default connection to test.
To view an existing database:
Copy Code code as follows:
To delete a database:
Copy Code code as follows:
Use <-database->//<-database-> the name of the database to be deleted
Db.dropdatabase ()
To Create a database:
Copy Code code as follows:
Use <-database->//<-database-> is the name of the database to create and it automatically creates the database and connects to the database
Deposit Data:
Copy Code code as follows:
Use test
A = {"name": "Moneyinto"}
B = {"Age": "23"}
Db.test.insert (a)//a,b stored in different locations
Db.age,insert (b)
View data:
Copy Code code as follows:
Use test
Db.test.find ()
Db.age.find ()
to delete age from database test:
Copy Code code as follows:
Db.age.remove ()//delete
Db.age.find ()//check to see if deleted
Continue to accumulate, continue to update!