zoukankan      html  css  js  c++  java
  • mongodb安装

    <pre name="code" class="python">1、下载MongoDB(64位)
    
    http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.9.tgz
    
    或
    
    http://pan.baidu.com/s/1mgyRB8c
    
    2、安装MongoDB(安装到/usr/local)
    
    复制代码
    tar zxvf mongodb-linux-x86_64-2.4.9.tgz
    mv mongodb-linux-x86_64-2.4.9 mongodb
    cd mongodb
    mkdir db
    mkdir logs
    cd bin
    vi mongodb.conf
    复制代码
    dbpath=/usr/local/mongodb/db
    logpath=/usr/local/mongodb/logs/mongodb.log
    port=27017
    fork=true
    nohttpinterface=true
    3、重新绑定mongodb的配置文件地址和访问IP
    
    /usr/local/mongodb/bin/mongod --bind_ip 192.168.32.34 -f /usr/local/mongodb/bin/mongodb.conf
    4、开机自动启动mongodb
    
    vi /etc/rc.d/rc.local
    /usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf
    5、重启一下系统测试下能不能自启
    
    #进入mongodb的shell模式 
    /usr/local/mongodb/bin/mongo
    #查看数据库列表 
    show dbs
    #当前db版本 
    db.version();
     
     use tt
    这样就创建了一个数据库,如果什么都不操作离开的话,这个库就会被系统删除.所以我们还要执行下面的命令:
    db.usr.insert({'name':'tompig'});
    db.usr.insert({'name':'tompig1','id':1});
    
    
    
    
    > use tt
    switched to db tt
    > db.usr.insert({'name':'tompig'});
    > db.usr.insert({'name':'tompig1','id':1});
    >  db.getCollectionNames();
    [ "system.indexes", "usr" ]
    > db.userInfo.find();
    > select * from user;
    Wed Jan 27 14:44:18.923 SyntaxError: Unexpected identifier
    > db.user.find();
    > db.usr.find()
    { "_id" : ObjectId("56a867082830668c6cd6a8e5"), "name" : "tompig" }
    { "_id" : ObjectId("56a867092830668c6cd6a8e6"), "name" : "tompig1", "id" : 1 }


    
                                        
    
  • 相关阅读:
    微信小程序HTTPS
    微信商城-1简介
    va_list
    Event log c++ sample.
    EVENT LOGGING
    Analyze Program Runtime Stack
    unknow table alarmtemp error when drop database (mysql)
    This application has request the Runtime to terminate it in an unusual way.
    How to check if Visual Studio 2005 SP1 is installed
    SetUnhandledExceptionFilter
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351064.html
Copyright © 2011-2022 走看看