【MongoDB】Serveral common command of MongoDb,mongodbserveral
In the recent days, since the overwork made me exhaused, on arrival to home I will go to bed, which leads to loss of blogs that should have been written in the past days.
Now I make a summay to all the commond of operating mongoDB.
First, you should run the mongoDB server. if the following picture exists, it means you has run the mongoDB successfully.
Secondly,after run the mongodb server, next should execute the mongodb client.
thirdly, we input the db.help command, we will find all the method to operate database/
In the above picture, it;s generally used in the development.
Notes, in the mongodb, there is no command like mysql ('create database xxx'), instead use command 'use dbname' to create a new db;
Lastly I set a simple exampe to show usage of some command.
我之前也遇到过类似的问题,个人分析是数据的问题,在网上查信息说要删掉mongod.lock文件就重启就可以了,但是在我的机子上依然出现上述问题。
如果之前一直好好的,仅仅是因为插入了数据导致服务无法使用,处理问题的方法就很简单了,把你刚刚复制的数据和mongod.lock文件删掉(都在data文件夹下)。有可能是因为mongodb-win32-i386-2.2.1这个版本的某个文件夹下有你刚刚复制进去的数据,数据的重复导致只删掉mongod.lock无法启动。
注:mongodb在mongodb-win32-i386-2.2.1这版本的时候,数据存储在data文件夹会自己创建文件夹(之前是直接以.ns .0 .1的格式保存在data文件夹下)。
这是我的自己尝试出来的方法。具体原因我也分析不出来,希望能帮到你。
这不是mongodb无法启动,是你还没有启动mongodb就来连接使用它了,肯定是不成功的。
先去mongodb的bin目录下运行mongod --dbpath XXXX/data 来启动mongodb,然后再来连接mongodb。