Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. # MongoDB {{tag>mongo nosql}} ## 문서 - [[MongoDB 필드 삭제]] - [[save pickle]] - [[Mongodb Log file]] - [[Mongodb Repair]] - [[Mongodb Regex]] ## 로그 파일 삭제 <code> # /var/log/mongodb/mongod.log sudo cp /dev/null mongod.log </code> ## 도커에서 인증 활성화 - https://stackoverflow.com/questions/34559557/how-to-enable-authentication-on-mongodb-through-docker/43441619#43441619 ### docker run <code> $ docker run -d --rm --name mongo_remote_container \ -p 27000:27017 \ -e MONGO_INITDB_ROOT_USERNAME=admin \ -e MONGO_INITDB_ROOT_PASSWORD=secret_password \ mongo \ mongod --auth </code> <code> docker run -d --rm --name mongo_remote_container \ -e MONGODB_ADMIN_USER=admin \ -e MONGODB_ADMIN_PASS=secret_admin_pa$$ \ -e MONGODB_APPLICATION_DATABASE=mytestdatabase \ -e MONGODB_APPLICATION_USER=testuser \ -e MONGODB_APPLICATION_PASS=testpass \ -p 27000:27017 aashreys/mongo-auth:latest \ </code> <code> db.auth('admin', 'secret_admin_pa$$') </code> ## mongodb find ### regex ```json db.getCollection('wine_collection').find({'name_ko': {'$regex' : ".*마르케시 디 바롤로, 사르마싸.*"}}) ``` ### elemMatch ```json db.getCollection('wine_collection').find({"varieties" : {'$elemMatch' : {"$eq": "네비올로"}}}) ``` ## 링크 - http://dev.youngkyu.kr/23 ## 특정 필드를 가지고 있는 문서 조회 ```db db.getCollection('stock_company').find({'daily_updated': {'$exists': true}}).count() ``` ## 특정 필드 삭제 `$unset` 사용 `multi: true` 를 지정하여 여러 문서에 적용 <code> db.getCollection('stock_company').update({}, {'$unset': {'daily_updated': ''}}, {'multi': true}) </code> 여러 필드를 삭제하는 경우 <code> db.getCollection('stock_company').update({}, {'$unset': {'daily_updated': '', 'second_field': ''}}, {'multi': true}) </code> open/mongodb.txt Last modified: 2024/10/05 06:15by 127.0.0.1