mongodb linux使用yum安裝 遠端連線
1安裝mongodb資料庫:
yum -y install mongodb-server mongodb
service mongod start #啟動mongodb 服務
pstree -p | grep mongod #程序列表
chkconfig mongod on #開機啟動mongod服務
2.進入mongodb資料庫:
mongo # 進入mongodb命令列模式
show dbs #顯示所有的表
db #當前資料庫
show tables #當前資料庫多少個集合
show collections #當前資料庫多少個集合[*]
建立命令:
db.c1.insert({name:”tom”}); #往表新增一條資料
show dbs #顯示當前test資料庫
show tables #當前資料庫多少個集合
db.c1.find(); #檢視資料列表
MongoDB使用教程:[1]Linux下安裝MongoDB
刪除命令:
方法一:刪除整張表
db.c1.remove(); #刪除表所有資料
db.c1.find(); #檢視資料列表
方法二:刪除一條資料
db.c1.remove({sex:”man”});
db.c1.find()
MongoDB使用教程:[1]Linux下安裝MongoDB
MongoDB使用教程:[1]Linux下安裝MongoDB
修改命令:
方法一
db.c1.insert({name:”tom”}); #往表新增一條資料
db.c1.update({name:”tom”},{name:”tom_up”}); #更新資料
方法二
db.c1.insert({name:”tom”,age:25})
db.c1.find()
db.c1.update({name:”tom”},{$set:{name:”tom-up”}})
db.c1.find()
方法三
db.c1.update({name:”tom-up”},{$set:{sex:”man”}});
db.c1.find()
MongoDB使用教程:[1]Linux下安裝MongoDB
MongoDB使用教程:[1]Linux下安裝MongoDB
MongoDB使用教程:[1]Linux下安裝MongoDB
遠端連線設定
修改配置中的ip才能遠端連線
vi /etc/mongod.conf
將bind_ip=127.0.0.1 註釋或者刪掉
然後esc退出 然後 :eq退出儲存