1.On the Linux server where MongoDB Server is installed, open a command prompt and run the rpm -qa|grep mongo command to check whether MongoDB service exists.
2.Run the rpm -e mongodbconfig command to uninstall MongoDB service.
Note: After the service is uninstalled, both the mongod.conf file and all data files are backed up under the /opt/mongodb directory with the timestamp if you did not modify it in the install_mongodb.conf file during the MongoDB installation. You can run the ls -al command under the /opt/mongodb directory to check the backup data.
[root@localhost mongodb]# ls -al
total 124
drwxr-xr-x. 3 netbrain netbrain 146 Oct 19 14:49 .
drwxr-xr-x. 3 root root 42 Oct 19 14.41 ..
drwxr-xr-x. 4 netbrain netbrain 86016 Oct 19 14.47 data2017|Oct|19|10:15:00
drwxr-xr-x. 1 netbrain netbrain 1147 Oct 19 14.27 mongod.conf2017|Oct|19|10:15:50