Linux MintにMongoDBをインストール

目次
やりたいこと&環境
LinuxにMongoDBをインストールしたい。
apt-getで簡単にインストールしたい。
実行環境:LinuxMint 17.3
実行コマンド
参考:公式web
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
インストール実行
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 $ echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list $ sudo apt-get update $ sudo apt-get install -y mongodb-org
サービス起動・停止
$ sudo service mongod start // サービス起動 $ sudo service mongod stop // サービス停止
デフォルトの設定ファイル
/etc/mongod.conf
ログ出力先
/var/log/mongodb/mongod.log
mongoShell
実行
$ mongo MongoDB shell version: 3.2.7 connecting to: test Welcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, see http://docs.mongodb.org/ >
現在のDB確認
> db test
DB変更
> use dbName switched to db dbName > db dbName
存在しないDB(いきなり新しいDB名)でも問題なし。
Insertと全件Select
// Insert > db.myCollection.insert({x: 1, y: 2}); WriteResult({ "nInserted" : 1 }) // 全件Select > db["myCollection"].find() { "_id" : ObjectId("576525760637c199bf148cde"), "x" : 1, "y" : 2 }
mongoShell終了
exit
または
quit()
MEAN環境の一歩。
- 前の記事
CentOS6.8にyumでMySQLをバージョン指定インストール 2016.06.06
- 次の記事
CentOS7へMongoDBインストール 2016.08.09