Repair Mac brew Installation mongodb report Error: No available with the name 'mongodb' problem details
- 2020-12-10 00:55:40
- OfStack
According to the official explanation of ES1en-ES2en, MongoDB is no longer open source and #43770 has been removed from Homebrew
It is because MongoDB's commercialization is not ideal that it chooses closed source. As a result, the brew installation methods reported errors before it closed the source. Many of the articles on the web are based on the old installation method, which prevented brew from being installed and reported errors.
Error: No available formula with the name ' mongodb'
New installation can reference github homepage, https: / / github com/mongodb/homebrew - brew.
The new installation tells us that we need to perform:
brew tap mongodb/brew
Then in execution:
brew install mongodb-community
This is the community version of the installation. If you need to install the specified version, you can bring the @ version number.
brew install mongodb-community@4.2
brew install mongodb-community@4.0
brew install mongodb-community@3.6
If you just want to install the latest mongoshell, you can execute the following command.
brew install mongodb-community-shell
If an Download failed or DownloadError: Failed to download resource "ES42en-ES43en" error occurs, repeat the installation command and proceed with the download. This is your network problem. Try it more often.
The default configuration file path after installation is as follows:
# Configuration file: /usr/local/etc/mongod.conf
# Log directory path: /usr/local/var/log/mongodb
# Data directory path: /usr/local/var/mongodb
With brew, it is easy to start and stop Mongo.
# Start the
brew services start mongodb-community
# or
brew services start mongodb/brew/mongodb-community
# stop
brew services stop mongodb-community
# or
brew services stop mongodb/brew/mongodb-community
After installation, we need to do some configuration to prevent mongo from running naked. There have been many data leakage accidents over the years, so we need to configure 1 for security certification.
First, after we successfully start mongo, execute the following command:
# link mongo
mongo
# switch db , or create xttblog
use xttblog
# Create a user admin
db.createUser({
user:'admin',
pwd:'admin',
roles:[{role:'readWrite',db:'xttblog'}]
})
If created successfully, prompt: Successfully added user.
Successfully added user: {
"user" : "admin",
"roles" : [
{
"role" : "readWrite",
"db" : "xttblog"
}
]
}
Role Settings note that defaults such as userAdminAnyDatabase are no longer available. You can view roles using the show roles command.
# Check the role
show roles
# To view the user
show users
If you want to modify the user role, you can execute the db.updateUser command.
brew tap mongodb/brew
0
Once the operation is complete, we can modify the configuration file of mongo to enable authentication.
brew tap mongodb/brew
1
At the end of the file, add: configuration after # Enable permission validation.
brew tap mongodb/brew
2
Restart the service. To operate mongo again requires authentication.
mongo
use xttblog
db.auth("xttblog","xttblog")
The same SpringBoot integrated Mongo's url has to be configured with password authentication.
brew tap mongodb/brew
4
Now that the MongoDB installation is complete, check out the links below for more information on installing mongodb errors