20160918學習筆記 安裝并使用mongodb

20160918學習筆記

數據庫排行榜

http://db-engines.com/en/ranking

下載并安裝mongodb

mongodb-linux-x86_64-ubuntu1604-3.2.8.tgz
tar zxvf mongodb-linux-x86_64-ubuntu1604-3.2.8.tgz
mv mongodb-linux-x86_64-ubuntu1604-3.2.8 mongodb
cd mongodb

第二種安裝方式

apt-get install mongodb

啟動并使用mongodb

mkdir my_db
./bin/mongod --dbpath=./my_db
cd bin
./mongo
show dbs;
db.users.insert({'name':'liwei'});
show collections;
db.users.find();

db.users.insert({'name':'yulong','age':18});


db.users.insertMany([
    {'name':'xiaowang','age':16,'height':170},
    {'username':'canglaoshi','xiongwei':'d'}
]);

db.users.find().toArray();
db.users.find().pretty();

db.users.update({'name':'yulong'},{$set:{'age':20}});
db.users.update({條件},{更新的內容},{是否插入數據},{是否更新多條數據});
db.users.update({name:'liwei'},{$set:{weight:130}});

db.users.remove({name:"liwei"});

遇到的問題

  1. F CONTROL [main] Failed global initialization: BadValue: Invalid or no user locale set. Please ensure LANG and/or LC_* environment variables are set correctly.
    解決辦法:
    vim /etc/profile
    export LC_ALL=C

或者直接在終端里輸入 export LC_ALL=C

作業

  1. 3個頁面(首頁,列表頁,詳情頁)
  2. 練習mongodb,整理一個完整的文檔(markdown)
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容