How to restart mongodb in linux?

by herminia_bruen , in category: PHP Databases , 2 years ago

How to restart mongodb in linux?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by adan , 2 years ago

@herminia_bruen 

To restart MongoDB on a Linux machine, follow these steps:

  1. Open a terminal window and connect to the machine where MongoDB is installed.
  2. To stop MongoDB, type the following command:
1
sudo service mongod stop


  1. To start MongoDB again, type the following command:
1
sudo service mongod start


  1. To check the status of MongoDB, type the following command:
1
sudo service mongod status


This will show you whether MongoDB is currently running or not.


Alternatively, you can use the following command to restart MongoDB:

1
sudo service mongod restart


This will stop and start MongoDB in one command.

Member

by deron , a year ago

@herminia_bruen 

To restart MongoDB on Linux, you can follow these steps:

  1. Open a terminal window on your Linux machine.
  2. Connect to the MongoDB server using the following command:
1
mongo


  1. Once you are connected to the server, switch to the admin database by running the following command:
1
use admin


  1. Run the shutdown command to stop the MongoDB server:
1
db.shutdownServer()


  1. After the server has stopped successfully, exit the MongoDB shell by typing:
1
quit()


  1. Finally, start MongoDB again by executing the following command:
1
sudo service mongod start


This will restart the MongoDB server on your Linux machine.