mongodb停止遇到shutdownServer failed: unauthorized: this command must run from localhost when running db without auth解决方法

本文涉及的产品
云数据库 MongoDB,独享型 2核8GB
推荐场景:
构建全方位客户视图
简介:

停止mongodb 
use admin 
db.shutdownServer(); 

mongos> db.shutdownServer(); 
assert failed : unexpected error: "shutdownServer failed: unauthorized: this command must run from localhost when running db without auth" 
Error: Printing Stack Trace 
    at printStackTrace (src/mongo/shell/utils.js:37:15) 
    at doassert (src/mongo/shell/assert.js:6:5) 
    at assert (src/mongo/shell/assert.js:14:5) 
    at DB.shutdownServer (src/mongo/shell/db.js:346:9) 
    at (shell):1:4 
Tue Sep 23 16:46:51.328 assert failed : unexpected error: "shutdownServer failed: unauthorized: this command must run from localhost when running db without auth" at src/mongo/shell/assert.js:7 

mongo localhost:27021/admin 登录进去 
mongos> use admin 
switched to db admin 
mongos> db.shutdownServer(); 
Tue Sep 23 16:47:51.595 DBClientCursor::init call() failed 
server should be down... 
Tue Sep 23 16:47:51.599 trying reconnect to localhost:27021 
Tue Sep 23 16:47:51.599 reconnect localhost:27021 failed couldn't connect to server localhost:27021 

 

直接:

 ./bin/mongo localhost:21000/admin --eval "db.shutdownServer({force:true})"
















本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/bonelee/p/6293234.html,如需转载请自行联系原作者

相关实践学习
MongoDB数据库入门
MongoDB数据库入门实验。
快速掌握 MongoDB 数据库
本课程主要讲解MongoDB数据库的基本知识,包括MongoDB数据库的安装、配置、服务的启动、数据的CRUD操作函数使用、MongoDB索引的使用(唯一索引、地理索引、过期索引、全文索引等)、MapReduce操作实现、用户管理、Java对MongoDB的操作支持(基于2.x驱动与3.x驱动的完全讲解)。 通过学习此课程,读者将具备MongoDB数据库的开发能力,并且能够使用MongoDB进行项目开发。   相关的阿里云产品:云数据库 MongoDB版 云数据库MongoDB版支持ReplicaSet和Sharding两种部署架构,具备安全审计,时间点备份等多项企业能力。在互联网、物联网、游戏、金融等领域被广泛采用。 云数据库MongoDB版(ApsaraDB for MongoDB)完全兼容MongoDB协议,基于飞天分布式系统和高可靠存储引擎,提供多节点高可用架构、弹性扩容、容灾、备份回滚、性能优化等解决方案。 产品详情: https://www.aliyun.com/product/mongodb
相关文章
|
3月前
|
NoSQL MongoDB Python
【Python】已完美解决(MongoDB安装报错)Service ‘MongoDB Server (MongoDB)’ (MongoDB) failed tostart
【Python】已完美解决(MongoDB安装报错)Service ‘MongoDB Server (MongoDB)’ (MongoDB) failed tostart
186 1
|
NoSQL MongoDB
启动mongodb报错 Failed to set up listener: SocketException: Address already in use 解决办法
启动mongodb报错 Failed to set up listener: SocketException: Address already in use 解决办法
1050 1
|
5月前
|
NoSQL 关系型数据库 MongoDB
实时计算 Flink版操作报错之使用mongodb cdc时报错Command failed with error 40573,是什么导致的
在使用实时计算Flink版过程中,可能会遇到各种错误,了解这些错误的原因及解决方法对于高效排错至关重要。针对具体问题,查看Flink的日志是关键,它们通常会提供更详细的错误信息和堆栈跟踪,有助于定位问题。此外,Flink社区文档和官方论坛也是寻求帮助的好去处。以下是一些常见的操作报错及其可能的原因与解决策略。
|
5月前
|
NoSQL MongoDB 数据库
MongoDB【部署 03】Windows系统安装mongodb并设置用户名密码(无需安装mongosh)及SpringBoot集成报错 Command failed with error 18
MongoDB【部署 03】Windows系统安装mongodb并设置用户名密码(无需安装mongosh)及SpringBoot集成报错 Command failed with error 18
495 0
|
11月前
|
NoSQL MongoDB
解决 :MongoDB couldn‘t add user: not authorized on ‘your db‘ to execute command
解决 :MongoDB couldn‘t add user: not authorized on ‘your db‘ to execute command
454 0
|
11月前
|
NoSQL MongoDB
connect-mongo无法连接到mongodb报错Error: failed to connect to [undefined:27017]
connect-mongo无法连接到mongodb报错Error: failed to connect to [undefined:27017]
|
NoSQL MongoDB PHP
Yii2使用Mongodb配置并解决SyntaxError: missing ] after element list以及Authentication failed
Yii2使用Mongodb配置并解决SyntaxError: missing ] after element list以及Authentication failed
296 0
Yii2使用Mongodb配置并解决SyntaxError: missing ] after element list以及Authentication failed
|
1月前
|
存储 NoSQL 关系型数据库
非关系型数据库-MongoDB技术(二)
非关系型数据库-MongoDB技术(二)