Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MongoDB-4.2.2 installs and configures the account password for access

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

0. Purpose

Download MongoDB and install it to set password access.

The following three installation packages will be downloaded from the MongoDB official website

Mongodb-org-server-4.2.2-1.el6.x86_64.rpm # MongoDB services, configuration files, startup scripts

Mongodb-org-shell-4.2.2-1.el6.x86_64.rpm # contains shell commands related to mongo operations

Mongodb-org-tools-4.2.2-1.el6.x86_64.rpm # toolset for backup and analysis of MongoDB

1. Install server# rpm-ivh mongodb-org-server-4.2.2-1.el6.x86_64.rpm# / etc/init.d/mongod startstarting mongod: [OK] 2. The installation command line is used to login to mongodb# rpm-ivh mongodb-org-shell-4.2.2-1.el6.x86_64.rpm# mongo > show dbs;admin 0.000GBconfig 0.000GBlocal 0.000GB3. Set the administrator password for MongoDB > use adminswitched to db admin > db.createUser ({user: "admin", pwd: "test123", roles: [{role: "userAdminAnyDatabase", db: "admin"}]}) Successfully added user: {"user": "admin_root", "roles": [{"role": "userAdminAnyDatabase" "db": "admin"}]} # # verify login If 1 is returned, it proves that the password is valid > db.auth ("admin", "test123") 14. Create a db library test And assign account and password * # login administrator > use admin > db.auth ("admin", "test123") # create test library > use test > db.createUser ({user: "test", pwd: "test123", roles: [{role: "dbOwner", db: "test"}]}) Successfully added user: {"user": "test", "roles": [{"role": "dbOwner" "db": "test"}]} # the program can call the following link: some failures that cannot be started in mongodb://test:test123@localhost/test operation and maintenance

1. After the service restart, there will be a problem that it cannot be opened. Look up the log as follows

# / etc/init.d/mongod startstarting mongod: [FAILED] # tail-f / var/log/mongdb/mongod.log2019-12-25T10:43:44.336+0800 I CONTROL [initandlisten] distarch: x86 * 642019-12-25T10:43:44.336+0800 I CONTROL [initandlisten] target_arch: x86 * 642019-12-25T10:43:44.336+0800 I CONTROL [initandlisten] options: {config: "/ etc/mongod.conf" Net: {bindIp: "127.0.0.1", port: 27017}, processManagement: {fork: true, pidFilePath: "/ var/run/mongodb/mongod.pid", timeZoneInfo: "/ usr/share/zoneinfo"}, storage: {dbPath: "/ var/lib/mongo", journal: {enabled: true}}, systemLog: {destination: "file", logAppend: true Path: "/ var/log/mongodb/mongod.log"} 2019-12-25T10:43:44.336+0800 E NETWORK [initandlisten] Failed to unlink socket file / tmp/mongodb-27017.sock Operation not permitted2019-12-25T10:43:44.336+0800 F-[initandlisten] Fatal Assertion 40486 at src/mongo/transport/transport_layer_asio.cpp 6932019-12-25T10:43:44.336+0800 F-[initandlisten] * * aborting after fassert () failure

Solution:

# rm-fr / tmp/mongodb-27017.sock# / etc/init.d/mongod startstarting mongod: [OK]

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report