In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
How do I install the mongodb database and create users in Mac? In view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
Install mongodb
There are three ways to install mongodb:
1. Download and install directly
MongoDB provides a 64-bit installation package on the OSX platform, which you can download from the official website.
Download address: [https://www.mongodb.com/download-center#community][1]
2. Install through the curl that comes with mac
# enter / usr/localcd / usr/local# to download sudo curl-O https://fastdl.mongodb.org/osx/mongodb-osx-x86_64-3.4.2.tgz# to extract sudo tar-zxvf mongodb-osx-x86_64-3.4.2.tgz# and rename it to the mongodb directory sudo mv mongodb-osx-x86_64-3.4.2 mongodb
3. Install via brew
Sudo brew install mongodb
Create new log files, mongodb configuration files and database storage paths
(add sudo before the command if the following folder creation is not successful or prompts that you do not have permission)
# enter mac root directory cd / mongoData# new folder mongoDatamkdir mongoData# create three new folders: db (store database data), etc (mongodb configuration file), logs (log file) mkdir db etc logs create configuration file and log file cd etctouch mongo.confcd logs touch mongo.log under etc and log, respectively
Next, modify the configuration file of mongodb
# vim Editing configuration File vim mongo.conf
There are many configuration file fields for mongdb. Let me show you my profile.
# Database path dbpath=/mongoData/db/# log output file path logpath=/mongoData/logs/mongo.log# error log uses append mode. After configuring this option, the log of mongodb will be appended to the existing log file instead of creating a new file logappend=true# to enable log file. By default, enable journal=true# this option can filter out some useless log information. If you need to debug, set it to whether falsequiet=false# is started in the background. With this parameter, you can run fork=true# in the background. The default port number is 27017port=27017# specified storage engine (default does not need to be specified) # storageEngine=mmapv1# enables authentication auth = true
Copy the configuration fields above and save them
Start mongodb
# enter the mongdb installation directory cd / usr/local/mongodb/bin# to start mongdb./mongod-f / mongoData/etc/mongo.conf through the configuration file
If successful appears, the service has been started successfully.
Configure superusers and users
# enter mongodb./mongo# and use admin database use admin# to view all databases show dbs
If nothing happens, it will indicate that there is no permission, because we started the mongodb with a configuration file, and in the configuration file, we turned on authentication and set the auth field to true.
At this time, we should start to configure users.
Create a Super Admin user
Use admindb.createUser ({user: "admin", pwd: "password", roles: ["root"]}) / / admin this database is the system's own database, his users can access the data of any other database, also known as super administrator db.auth ("admin", "password") / / = > 1 indicates that the verification passed 0 indicates that the verification failed show dbs / / = > admin 0.000GB blog 0.000GB config 0.000GB
This shows all the databases.
Create a normal user (a user of a database)
Use admin / / = > enter admin database db.auth ("admin", "password") / / = > verify through Super Admin use blogdb.createUser ({user: "blog", pwd: "password", roles: [{role: "dbOwner", db: "blog"}]}) show dbs = > admin 0.000GB blog 0.000GB config 0.000GB local 0.000GB 's questions on how to install mongodb database in Mac and create users are shared here I hope the above content can help you to a certain extent, if you still have a lot of doubts to be solved, you can follow the industry information channel to learn more related knowledge.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.