1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| vim /etc/yum.repos.d/mongodb.repo [MongoDB] name=MongoDB baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/ enabled=1 gpgcheck=0 yum install mongodb-org -y
systemctl start mongod.service mongo --port 27017 #通过命令行登录mongo,建立用户。 > use admin > db.createUser({user: 'admin', pwd: 'admin123',roles:[{role:'root',db:'admin'}]}) Successfully added user: { "user" : "admin", "roles" : [ { "role" : "root", "db" : "admin" } ] }
vim /etc/mongod.conf net: port: 27017 bindIp: 0.0.0.0 # 修改,配置远程连接ip security: #添加 authorization: enabled #添加权限认证配置 systemctl restart mongod.service
|