By default mongodb instance run on port 27017.
1 |
Tue Nov 5 23:59:56 [initandlisten] MongoDB starting : pid=24373 port=27017 dbpath=/data/db/ 64-bit host=thosan-hp |
There are two options to change the default port of mongodb.
- pass the –port argument when we start mongod.
- change the port in the mongodb.config file and pass the config file as input.
1 2 |
thosan@thosan-hp ~ $ mongod --port 19000 Wed Nov 6 13:08:34 [initandlisten] MongoDB starting : pid=26120 port=19000 dbpath=/data/db/ 64-bit host=thosan-hp |
To connect to mongod running on port 19000 we need to start the mongo also with –port argument.
1 2 3 |
hosan@thosan-hp ~/java/gitrepo/sr $ mongo --port 19000 MongoDB shell version: 2.2.4 connecting to: 127.0.0.1:19000/test |
Alternatively you can change the port in /etc/mongodb.config
1 2 3 4 5 6 7 8 9 10 11 12 |
# mongodb.conf # Where to store the data. dbpath=/data/db #where to log logpath=/tmp/log/rmongodb/mongodb.log logappend=true bind_ip = 127.0.0.1 port = 21000 |
1 2 3 4 |
thosan@thosan-hp ~ $ mongod --config /etc/mongodb.conf all output going to: /tmp/log/rmongodb/mongodb.log can't open [/tmp/log/rmongodb/mongodb.log] for log file: errno:2 No such file or directory Wed Nov 6 13:15:42 [initandlisten] MongoDB starting : pid=26272 port=21000 dbpath=/data/db 64-bit host=thosan-hp |
Please visit site https://movietone-portraits.com/.