mogodb 설치 시작 및 간단 한 사용 명령

2541 단어 Go

Mongodb 다운로드
  wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-2.0.7.tgz
압축 해제 설치
  tar zxvf mongodb-linux-i686-2.0.7.tgz
  cp mongodb-linux-i686-2.0.7 /usr/local/mongodb-2.0.7
  cd /usr/local/mongodb-2.0.7
  touch mongodb-start.sh
  mkdir data
  touch dblogs
  
  ##mongodb-start.sh     
  #!/bin/bash
  
  MONGODB_HOME=`echo $(cd .;pwd)`
  echo $MONGODB_HOME
  ${MONGODB_HOME}/bin/mongod \
       --dbpath=${MONGODB_HOME}/data/ \
       --logpath=${MONGODB_HOME}/dblogs \
       --fork
mongodb 시작
  chmod a+x mongodb-start.sh
  ./mongodb-start.sh
            :
  /usr/local/mongodb-2.2
  forked process: 6739
  all output going to: /usr/local/mongodb-2.2/dblogs
  log file [/usr/local/mongodb-2.2/dblogs] exists; copied to temporary file [/usr/local/mongodb-2.2/dblogs.2012-09-13T01-56-36]
  child process started successfully, parent exiting
  
     mongodb    。
    
mongodb 사용
      :
   ./mongo
  MongoDB shell version: 2.2.0
  connecting to: test
  > dbs;
  Thu Sep 13 09:57:06 ReferenceError: dbs is not defined (shell):1
  > show dbs;
  local	(empty)
  > use test;
  switched to db test
  > show db;
  Thu Sep 13 09:57:41 uncaught exception: don't know how to show [db]
  > show dbs;
  local	(empty)
  > db.createCollection("mycoll");
  { "ok" : 1 }
  > show tables;
  mycoll
  system.indexes
  > db.mycoll.insert({a:10,b:19});
  > db.mycoll.find();
  { "_id" : ObjectId("50513e01cfbe829a0607489d"), "a" : 10, "b" : 19 }
  > db.mycoll.insert({a:11,b:29});
  > db.mycoll.find();
  { "_id" : ObjectId("50513e01cfbe829a0607489d"), "a" : 10, "b" : 19 }
  { "_id" : ObjectId("50513e23cfbe829a0607489e"), "a" : 11, "b" : 29 }
  > db.mycoll.findOne();
  { "_id" : ObjectId("50513e01cfbe829a0607489d"), "a" : 10, "b" : 19 }
  > db.mycoll.count();
  2
            [http://www.mongodb.org/display/DOCS/SQL+to+Mongo+Mapping+Chart]

좋은 웹페이지 즐겨찾기