You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
查看锚点为:What’s new in Spring Data MongoDB 的内容,比如:What’s new in Spring Data MongoDB 1.10,出现这样一句话:Compatible with MongoDB Server 3.4 and the MongoDB Java Driver 3.4
tar zxvf mongodb-linux-x86_64-rhel62-3.4.10.gz
mv mongodb-linux-x86_64-rhel62-3.4.10 mongodb
mv mongodb /usr/program
增加系统变量,我这里是用 zsh
vim ~/.zshrc
export MONGODB_HOME=/usr/program/mongodb
export PATH=$MONGODB_HOME/bin:$PATH
source ~/.zshrc
测试是否安装成功:mongod -v,安装成功会得到如下信息:
2017-12-03T00:08:09.854+0800 I CONTROL [initandlisten] MongoDB starting : pid=31155 port=27017 dbpath=/data/db 64-bit host=youmeek
2017-12-03T00:08:09.854+0800 I CONTROL [initandlisten] db version v3.4.10
2017-12-03T00:08:09.854+0800 I CONTROL [initandlisten] git version: 078f28920cb24de0dd479b5ea6c66c644f6326e9
2017-12-03T00:08:09.854+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2017-12-03T00:08:09.854+0800 I CONTROL [initandlisten] allocator: tcmalloc
2017-12-03T00:08:09.854+0800 I CONTROL [initandlisten] modules: none
2017-12-03T00:08:09.854+0800 I CONTROL [initandlisten] build environment:
2017-12-03T00:08:09.854+0800 I CONTROL [initandlisten] distmod: rhel62
2017-12-03T00:08:09.854+0800 I CONTROL [initandlisten] distarch: x86_64
2017-12-03T00:08:09.854+0800 I CONTROL [initandlisten] target_arch: x86_64
2017-12-03T00:08:09.854+0800 I CONTROL [initandlisten] options: { systemLog: { verbosity: 1 } }
2017-12-03T00:08:09.854+0800 D - [initandlisten] User Assertion: 29:Data directory /data/db not found. src/mongo/db/service_context_d.cpp 98
2017-12-03T00:08:09.854+0800 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2017-12-03T00:08:09.854+0800 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-12-03T00:08:09.854+0800 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-12-03T00:08:09.854+0800 I CONTROL [initandlisten] now exiting
2017-12-03T00:08:09.854+0800 I CONTROL [initandlisten] shutting down with code:100
db.集名称.update({name:"张三"},{$set:{name:"李四"}}),更新数据,等同于:UPDATE 表名 SET name='李四' WHERE name = '张三'
db.集名称.update({name:"张三"},{$set:{name:"李四"},{upsert:true},{multi:true}}),更新数据,等同于:UPDATE 表名 SET name='李四' WHERE name = '张三'。其中特殊的是 upsert 为 true 的时候,表示如果没有这条数据,则创建一条。multi 表示,所有满足条件的都进行更新,不然默认只找到的第一条更新。
db.集名称.remove({name:"lichuang"}),删除数据,等同于:DELETE FROM 表名 WHERE name='lichuang'