I am a Quantitative Analyst/Developer and Data Scientist with backgroud of Finance, Education, and IT industry. This site contains some exercises, projects, and studies that I have worked on. If you have any questions, feel free to contact me at ih138 at columbia dot edu.
$m = new MongoClient("mongodb://ipaddress"); $db = $m->mydb; $grid = $db->getGridFS(); $name = $_FILES['file_upload']['name']; // the name of the uploades file $id = $grid->storeUpload('Filedata', $name);
selectDB('test')->getGridFS(); $input = array('sql_id' => 143294 , 'question_id' => 900, 'filetype'=> 'image'); $gridfs->storeUpload('pic', $input); } ?>
Result at MongoDB
This makes normalized data which can be accessed by the additional information put when uploading.
http://docs.mongodb.org/master/MongoDB-security-guide.pdf
$ sudo service mongod startCheck if it started correctly.
2015-07-27T21:12:20.253+0000 D INDEX [initandlisten] checking complete 2015-07-27T21:12:20.253+0000 I NETWORK [initandlisten] waiting for connections on port 27017 2015-07-27T21:12:20.253+0000 D COMMAND [PeriodicTaskRunner] BackgroundJob starting: PeriodicTaskRunner 2015-07-27T21:12:20.253+0000 D COMMAND [ClientCursorMonitor] BackgroundJob starting: ClientCursorMonitor 2015-07-27T21:12:20.253+0000 D COMMAND [TTLMonitor] BackgroundJob starting: TTLMonitor 2015-07-27T21:13:20.227+0000 I STORAGE [DataFileSync] flushing mmaps took 0ms for 8 files
mongo > use admin > db.createUser( { user: "siteUserAdmin", pwd: "password", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] }); Successfully added user: { "user" : "siteUserAdmin", "roles" : [ { "role" : "userAdminAnyDatabase", "db" : "admin" } ] }
db.createUser( { user: "siteRootAdmin", pwd: "password", roles: [ { role: "root", db: "admin" } ] }); Successfully added user: { "user" : "siteRootAdmin", "roles" : [ { "role" : "root", "db" : "admin" } ] }
openssl rand -base64 741 > mongodb-keyfile chmod 600 mongodb-keyfileYou may generate a key file using any method you choose. Always ensure that the password stored in the key file is both long and contains a high amount of entropy. Using openssl in this manner helps generate such a key.
# path to a key file storing authentication info for connections # between replica set members keyFile=/home/ubuntu/.ssh/mongodb-keyfile
$ sudo mongod --config /etc/mongod.conf &
I CONTROL [initandlisten] allocator: tcmalloc I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", security: { keyFile: "/home/ubuntu/.ssh/mongodb-keyfile" }, storage: { dbPath: "/var/lib/mongodb" }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } } I NETWORK [initandlisten] waiting for connections on port 27017
$ mongo --port 27017 -u siteUserAdmin -p password --authenticationDatabase admin