MongoDB,V3.2版本,官网说的很详细,见连接:https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/mongodb
一、建立配置文件,shell
vi /etc/yum.repos.d/mongodb-org-2.6.repo数据库
[mongodb-org-3.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc
二、安装mongodbnpm
yum install -y mongodb-org服务器
三、启动mongodbmongoose
service mongod start测试
四、暂停服务url
service mongod stopspa
五、重启服务rest
service mongod restart
六、开机启动
chkconfig mongod on
另:能够重启一下服务器进行测试,shutdown -r now
七、安装mongoose
npm install mongoose --save
mongodb的CURD以下:
————进入mongo shell页面————
mongo
————建立数据库/建立表———— use testdatabase db.createCollection('testtable') ————显示全部表———— use testdatabase show collections ————插入数据———— use testdatabase coll = db.getCollection('testtable') coll.insert({name:"ZhangSan",password:"123456"}) coll.insert({name:"WangEr",password:"nicai"}) ————查询数据———— use testdatabase coll = db.getCollection('testtable') coll.find()