Mongodb pagoda online configuration

Time:2021-9-26

Recently, I want to write a background interface of personal blog with node and mongodb. After there is no problem in the local test, I want to deploy it online.

1. Install mongodb in the software store of pagoda

Mongodb pagoda online configuration

2. Configure Internet connection

  • Set the listening port to0.0.0.0, the original is127.0.0.1Only local access is allowed, and now Internet access is allowed

Mongodb pagoda online configuration

  • In the [security] configuration item of the pagoda, release port 27017

Mongodb pagoda online configuration

  • Add rules to the firewall in Tencent cloud [management console] to allow access to port 27017.

Mongodb pagoda online configuration

3. Configure account and password

  • Enter the mongodb installation directory. The following is the default directory of the pagoda panel

    cd /www/server/mongodb/bin

  • Enter the command line Mongo to enter the mongodb environment

    mongo

  • Set account and password for admin database

    • Switch to admin database
      use admin
    • Set user and password

      db.createUser({user:'root',pwd:'admin_mima',roles:['root']})
    • Verify whether the addition is successful, db.auth (user name, user password)
      db.auth('root', 'admin_mima')
  • Set account and password for other databases

    • Switch to myblog database
      use myblog
    • Set user and password

      db.createUser({user:'test',pwd:'123456',roles:['readWrite']})
    • Verify whether the addition is successful, db.auth (user name, user password)
      db.auth('test', '123456')

4. Enable secure login

authorizationChange from disable to enable
Mongodb pagoda online configuration

5. Settings in the project

  • Project location

Mongodb pagoda online configuration

  • Modify background project connection database configuration

Mongodb pagoda online configuration

  • Start background project

Download and start PM2 Manager
Mongodb pagoda online configuration

Add run item
Mongodb pagoda online configuration

6. Test

Mongodb pagoda online configuration

Solve the problem that pagoda mongodb cannot start:
Enter the mongodb directory on the pagoda command line
cd /www/server/mongodb/bin
Enter command:mongod
Problem solved, unknown reason

Recommended Today

Supervisor

Supervisor [note] Supervisor – H view supervisor command help Supervisorctl – H view supervisorctl command help Supervisorctl help view the action command of supervisorctl Supervisorctl help any action to view the use of this action 1. Introduction Supervisor is a process control system. Generally speaking, it can monitor your process. If the process exits abnormally, […]