mongo11---Access control is not enabled for the database
2018-01-02 10:09
387 查看
今天使用MongoDB时遇到了一些问题
建立数据库连接时出现了warnings
出现这个警告的原因是新版本的MongDB为了让我们创建一个安全的数据库
必须要进行验证
后来在外网找到了答案
解决方案如下:
创建管理员
重启MongoDB服务器
(端口默认就是27017可以不指定)
终端最后输出
启动完成
连接并认证
添加额外权限用户
MongoDB更新了,使用mongoose也不能简单的建立连接了
必须要添加必要参数
==主页传送门==
建立数据库连接时出现了warnings
出现这个警告的原因是新版本的MongDB为了让我们创建一个安全的数据库
必须要进行验证
后来在外网找到了答案
解决方案如下:
创建管理员
use admin db.createUser( { user: "userAdmin", //用户名 pwd: "123", //密码 roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] //权限 } )
重启MongoDB服务器
mongod --auth --port 27017 --dbpath <关联路径>
(端口默认就是27017可以不指定)
终端最后输出
"[initandlisten] waiting for connections on port 27017",
启动完成
连接并认证
mongo --port 27017 -u "userAdmin" -p "123" --authenticationDatabase "admin"
添加额外权限用户
use test db.createUser( { user: "tester", pwd: "123", roles: [ { role: "readWrite", db: "test" }, { role: "read", db: "reporting" } ] } )
mongo --port 27017 -u "myTester" -p "xyz123" --authenticationDatabase "test"
MongoDB更新了,使用mongoose也不能简单的建立连接了
必须要添加必要参数
var mongoose = require('mongoose'); var db = mongoose.createConnection('localhost', 'test', 27017, {user: 'tester', pass: '123'});
==主页传送门==
相关文章推荐
- Node.js使用MongoDB3.4+Access control is not enabled for the database解决方案
- mongodb access control is not enabled for the database
- mogodb创建用户:access control is not enabled for the database
- 启动MongoDB提示报警信息:“WARNING: Access control is not enabled for the database.”
- The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported.
- 删除sybase一列报错:The 'select into' database option is not enabled for database.....
- The SQL Server Service Broker for the current database is not enabled
- Could not allocate space for object in database because the filegroup is full
- Rails 4 - Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded
- SqlServer2005 恢复数据库时出现Exclusive access could not be obtained because the database is in use 的解决方法
- 安装Visual Studio 2010时提示"The location specified for the help content store is invalid or you do not have access to it".
- Issue: Server principal is not able to access the database under the current security context
- Error: 9001, Severity: 21, State: 5 The log for database 'xxxx' is not available
- WCF : 修复 Security settings for this service require Windows Authentication but it is not enabled for the IIS application that hosts this service 问题
- java.lang.IllegalStateException: Driver for test database type [H2] is not available in the classpat
- SqlServer2005 恢复数据库时出现Exclusive access could not be obtained because the database is in use 的解决方法
- Access to the database file is not allowed. [ File name = ***\DataBase.sdf
- The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the ser
- Exclusive access could not be obtained because the database is in use
- [Solved]: System.Data.SqlClient.SqlError: Exclusive access could not be obtained because the database is in use.