Unable to install mongodb properly on ubuntu 18.04 LTS

前端 未结 14 1302
盖世英雄少女心
盖世英雄少女心 2021-02-03 23:26

I am trying to install mongodb on my Ubuntu 18.04 LTS, but it has the following error saying

You might want to run \'apt --fix-broken install\' to correct

相关标签:
14条回答
  • 2021-02-04 00:11

    Try this, I successfully find this out

    $ sudo apt-get install -y mongodb
    
    0 讨论(0)
  • 2021-02-04 00:13

    Just run the command sudo apt install mongodb it will install the mongodb, because mongodb is now part of ubuntu repository. After installation run command sudo service mongodb start to start the mongodb server. Then if you run command mongo it will give you shell helper. To see the existing database use command show dbs. After successfull installation you will find there pre existing database names are admin, config, local. Use command db to see which database is currently running on server, there will a database named test or somthing. To add a collection (tables on SQL DB) just use the insert command with an initial document (row in SQL DB) information db.data.insert({"username":"Brad Pitt"})
    In previous command data is my collection name. Now to see all documents in data collection just use command db.data.find(); Other commands: sudo service mongod status, sudo service mongodb stop, sudo service mongod restart ,sudo service mongod stop.

    For more information, you can visit https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

    ;

    0 讨论(0)
提交回复
热议问题