mongoDB mongotop実行時にエラー「Failed: (Unauthorized) command top requires authentication」が発生した場合の対処法

mongoDB mongotop実行時にエラー「Failed: (Unauthorized) command top requires authentication」が発生した場合の対処法

mongotop実行時にエラー「Failed: (Unauthorized) command top requires authentication」が発生した場合の対処法を記述してます。

環境

  • OS Ubuntu 20.04
  • MongoDB 5.0.5

エラー全文

「mongotop」コマンド実行時に発生。

# mongotop

2021-12-23T03:00:10.327+0000    Failed: (Unauthorized) command top requires authentication

原因

mongotop実行時は「 –authenticationDatabase admin 」の指定が必要なため

対処法

ユーザー名とパスワードと「 –authenticationDatabase admin 」を指定して実行する

mongotop -u ユーザー名 -p パスワード名 --authenticationDatabase admin