如何使mongo-express显示所有数据库? [英] how to make mongo-express show all db?

查看:98
本文介绍了如何使mongo-express显示所有数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的mongo-express配置,当我登录 http://192.168.1.104:8081 时,它只显示管理数据库,我希望它显示所有数据库.我之前曾经运行过此命令

here is my mongo-express config, when i login http://192.168.1.104:8081, it only shows the admin db, i want it to show all db. i had ran this command before

use admin

db.createUser(
{
user: "root",
pwd: "password",
roles: [ "root" ]
}
)

配置文件:

'use strict';

var url = require('url');

if (typeof process.env.MONGODB_PORT === 'string') {
  var mongoConnection = url.parse(process.env.MONGODB_PORT);
  process.env.ME_CONFIG_MONGODB_SERVER = mongoConnection.hostname;
  process.env.ME_CONFIG_MONGODB_PORT = mongoConnection.port;
}

module.exports = {
  mongodb: {
    server: process.env.ME_CONFIG_MONGODB_SERVER || 'localhost',
    port: process.env.ME_CONFIG_MONGODB_PORT || 27017,

    //autoReconnect: automatically reconnect if connection is lost
    autoReconnect: true,
    //poolSize: size of connection pool (number of connections to use)
    poolSize: 4,
    //set admin to true if you want to turn on admin features
    //if admin is true, the auth list below will be ignored
    //if admin is true, you will need to enter an admin username/password below (if it is needed)
    admin: true,


    // >>>>  If you are using regular accounts, fill out auth details in the section below
    // >>>>  If you have admin auth, leave this section empty and skip to the next section
    auth: [
      /*
       * Add the the name, the username, and the password of the databases you want to connect to
       * Add as many databases as you want!
      {
        database: 'test',
        username: 'user',
        password: 'pass'
      }
      */
      ],


    //  >>>>  If you are using an admin mongodb account, or no admin account exists, fill out section below
    //  >>>>  Using an admin account allows you to view and edit all databases, and view stats

    //leave username and password empty if no admin account exists
    adminUsername: process.env.ME_CONFIG_MONGODB_ADMINUSERNAME || '',
    adminPassword: process.env.ME_CONFIG_MONGODB_ADMINPASSWORD || '',
    //whitelist: hide all databases except the ones in this list  (empty list for no whitelist)
    whitelist: [],
    //blacklist: hide databases listed in the blacklist (empty list for no blacklist)
    blacklist: []
  },

  site: {
    host: '192.168.1.104',
    port: 8081,
    cookieSecret: process.env.ME_CONFIG_SITE_COOKIESECRET || 'cookiesecret',
    sessionSecret: process.env.ME_CONFIG_SITE_SESSIONSECRET || 'sessionsecret',
    cookieKeyName: 'mongo-express',
    sslEnabled: process.env.ME_CONFIG_SITE_SSL_ENABLED || false,
    sslCert: process.env.ME_CONFIG_SITE_SSL_CRT_PATH || '',
    sslKey: process.env.ME_CONFIG_SITE_SSL_KEY_PATH || ''
  },

  //set useBasicAuth to true if you want to authehticate mongo-express loggins
  //if admin is false, the basicAuthInfo list below will be ignored
  //this will be true unless ME_CONFIG_BASICAUTH_USERNAME is set and is the empty string
  useBasicAuth: process.env.ME_CONFIG_BASICAUTH_USERNAME !== '',

  basicAuth: {
    username: process.env.ME_CONFIG_BASICAUTH_USERNAME || 'root',
    password: process.env.ME_CONFIG_BASICAUTH_PASSWORD || 'password'
  },

  options: {
    //documentsPerPage: how many documents you want to see at once in collection view
    documentsPerPage: 10,
    //editorTheme: Name of the theme you want to use for displaying documents
    //See http://codemirror.net/demo/theme.html for all examples
    editorTheme: process.env.ME_CONFIG_OPTIONS_EDITORTHEME || 'rubyblue',

    //The options below aren't being used yet

    //cmdType: the type of command line you want mongo express to run
    //values: eval, subprocess
    //  eval - uses db.eval. commands block, so only use this if you have to
    //  subprocess - spawns a mongo command line as a subprocess and pipes output to mongo express
    cmdType: 'eval',
    //subprocessTimeout: number of seconds of non-interaction before a subprocess is shut down
    subprocessTimeout: 300,
    //readOnly: if readOnly is true, components of writing are not visible.
    readOnly: false
  },

  // Specify the default keyname that should be picked from a document to display in collections list.
  // Keynames can be specified for every database and collection.
  // If no keyname is specified, it defalts to '_id', which is a mandatory feild.
  // For Example :
  // defaultKeyNames{
  //   "world_db":{  //Database Name
  //     "continent":"cont_name", // collection:feild
  //     "country":"country_name",
  //     "city":"name"
  //   }
  // }
  defaultKeyNames: {

  }
};

备注: 在上面的配置中, basicAuth:{ 用户名:process.env.ME_CONFIG_BASICAUTH_USERNAME || '根', 密码:process.env.ME_CONFIG_BASICAUTH_PASSWORD || '密码' }

Remarks: in above config, basicAuth: { username: process.env.ME_CONFIG_BASICAUTH_USERNAME || 'root', password: process.env.ME_CONFIG_BASICAUTH_PASSWORD || 'password' },

当我访问 http://192.168.1.104:8081 时,我分别将用户名,密码更改为root和密码.

,我需要在http auth提示符下输入root和密码,以便进入mongo-express Web面板.

i changed the username, password to root and password repectively, when i access http://192.168.1.104:8081 , i need to enter root and password in http auth prompt so as i entering the mongo-express web panel.

推荐答案

这是我对StackOverflow的第一个答案,但希望对您有所帮助.

This is my first answer on StackOverflow, but hopefully it's helpful.

在您的情况下,问题似乎是在config.js中定义的数据库身份验证. 您需要通过"auth"部分而不是"basicAuth"传递数据库凭据. 另外,更正config.js文件后,请使用-a开关(即-> cd YOUR_PATH/node_modules/mongo-express/ && node app.js -a

Issue in your case seems to be database authentication defined in config.js. You need to pass the db credentials through "auth" section and not through "basicAuth". Also, once you correct the config.js file, start the mongo-express with -a switch, i.e. -> cd YOUR_PATH/node_modules/mongo-express/ && node app.js -a

config.js的更正部分:

Corrected section of config.js :

admin: true,


// >>>>  If you are using regular accounts, fill out auth details in the section below
// >>>>  If you have admin auth, leave this section empty and skip to the next section
auth: [
  /*
   * Add the the name, the username, and the password of the databases you want to connect to
   * Add as many databases as you want!
  {
    database: 'test',
    username: 'user',
    password: 'pass'
  }
  */
  ],


//  >>>>  If you are using an admin mongodb account, or no admin account exists, fill out section below
//  >>>>  Using an admin account allows you to view and edit all databases, and view stats

//leave username and password empty if no admin account exists
adminUsername: process.env.ME_CONFIG_MONGODB_ADMINUSERNAME || 'root',
adminPassword: process.env.ME_CONFIG_MONGODB_ADMINPASSWORD || 'password',

这篇关于如何使mongo-express显示所有数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆