How to install MongoDB under Linux and basic operation under terminal

Source: Internet
Author: User
Tags install mongodb


to install MongoDB in a Linux environment:
even version is generally considered stable version such as 1.6.x, odd version for the development version such as 1.7.x
32bit MongoDB Max can store 2g of data, 64bit No limit

Method 1:
Terminal execution:
installation Server: sudo apt install mongodb-server
install client: sudo apt install mongodb-clients


Method 2:
1 Download the appropriate version of the website
2 Unzip to the/user/local/directory: TAR-ZXVF Install the package/user/local/mongodb
3 Add executable file to path path: Export path=/usr/local/mongodb/bin: $PATH



Basic Operation:

Server:
Start server: sudo service mongodb start
Stop server: sudo service MongoDB stop
restart server: sudo service mongodb restart
Note:
Some Linux systems are sudo service mong OD Start/stop/restart
Some people are sudo service MongoDB start/stop/restart
 

client:
connecting server:
MONGO
View parameters:
MONGO--help
exit MONGO Service:
exit or Ctr + C
View the database currently in use (the test database is used by default after login):
db
View all databases (physically created databases):
show dbs
switch database (use not present Library will temporarily build the library in memory, and creating the collection file will automatically create the database physically):
Use library name
Delete the currently used database (do nothing if the database does not exist):
Db.dropdatabase ()

How to install MongoDB under Linux and basic operation under terminal

Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.