linux下安裝mongodb的方法和終端下基本操作

來源:互聯網
上載者:User

標籤:終端   退出   mon   server   line   nts   span   rest   檔案   


在linux環境安裝mongoDB:
一般認為偶數版本為穩定版 如 1.6.x,奇數版本為開發版如1.7.x
32bit的mongoDB最大能存放2g的資料,64bit沒有限制

方法1:
終端執行:
安裝伺服器: sudo apt install mongodb-server
安裝用戶端: sudo apt install mongodb-clients


方法2:
1 官網下載合適版本
2 解壓到/user/local/目錄下: tar -zxvf 安裝壓縮包 /user/local/mongodb
3 添加可執行檔到path路徑: export PATH=/usr/local/mongodb/bin:$PATH



基本操作:

伺服器:
啟動伺服器: sudo service mongodb start
停止伺服器: sudo service mongodb stop
重啟伺服器: sudo service mongodb restart
    注意:
     有些linux系統是 sudo service mongod start/stop/restart
        有些人是 sudo service mongodb start/stop/restart


用戶端:
串連伺服器:
mongo
查看參數:
mongo --help
退出mongo服務:
exit 或 ctr + c
查看當前使用資料庫(登入後預設使用test資料庫):
db
查看所有資料庫(物理真實建立出來的資料庫):
show dbs
切換資料庫(use不存在的庫會在記憶體中臨時建庫,之後建立集合檔案會自動在物理上建立這個資料庫):
use 庫名
刪除當前使用的資料庫(如果資料庫不存在就什麼也不做):
db.dropDatabase()

linux下安裝mongodb的方法和終端下基本操作

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.