Linux下操作mongodb安装mongodb下载地址:http://www.mongodb.org/downloadscurl-Oh ttps://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.6.tgz #下载tar-zxvfmongodb-linux-x86_64-3.0.6.tgz#解压mvmongodb-linu x-x86_64-3.0.6//usr/local/mongodb#将解压包拷贝到指定目录启动mongodbcd/opt/ mongoDB/bin./mongod--dbpath=/opt/mongoDate/db/--logpath=/opt/mo ngoDB/log/mongodb.log--logappend&查看进程ps-ef|grepmongodb连接数据库./ mongo如果有用户名密码使用:./bin/mongo?ip?-u?username?-p显示数据库showdbs切换数据库us ecccc//cccc是数据库名showcollections;//显示集合查看集合db.aaaa.find()将mong odb服务加入到Linux下vi/etc/rc.local/opt/mongoDB/bin/mongod--dbpath=/o pt/mongoDate/db/--port27017--logpath=/opt/mongoDB/log/mongodb. log--logappend&重启服务sudoservicemongodbstart |
|