您好,登錄后才能下訂單哦!
今天就跟大家聊聊有關MongoDB制定路徑登陸創建的方法是什么,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結了以下內容,希望大家根據這篇文章可以有所收獲。
1.下載mongodb的系統包
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.9.tgz
2.解壓壓縮包
[root@oracle ~]# tar -zxvf mongodb-linux-x86_64-3.6.9.tgz
[root@oracle ~]# ls
anaconda-ks.cfg mongodb-linux-x86_64-3.6.9 模板 文檔 桌面
install.log mongodb-linux-x86_64-3.6.9.tgz 視頻 下載
install.log.syslog 公共的 圖片 音樂
3.將解壓包改名為在
[root@oracle ~]# cp -rf mongodb-linux-x86_64-3.6.9 /usr/local/mongodb-3.2
[root@oracle ~]# cd /usr/local/mongodb-3.2/bin/
[root@oracle bin]# ls
bsondump mongo mongodump mongofiles mongoperf mongorestore mongostat
install_compass mongod mongoexport mongoimport mongoreplay mongos mongotop
4.創建數據庫目錄
[root@oracle bin]# mkdir -p /data/mongodb/data
[root@oracle bin]# mkdir -p /data/mongodb/logs
[root@oracle bin]# touch /data/mongodb/logs/mongodb.log
[root@oracle bin]# /usr/local/mongodb-3.2/bin/mongod
mongod mongodump
5.啟動的MongoDB
[root@oracle bin]# /usr/local/mongodb-3.2/bin/mongod --dbpath=/data/mongodb/data/ --logpath=/data/mongodb/logs/mongodb.log --logappend -port=27017 --fork
about to fork child process, waiting until server is ready for connections.
forked process: 23372
child process started successfully, parent exiting
[root@oracle bin]# ls
bsondump mongo mongodump mongofiles mongoperf mongorestore mongostat
install_compass mongod mongoexport mongoimport mongoreplay mongos mongotop
6.進入數據庫
[root@oracle bin]# ./mongo
MongoDB shell version v3.6.9
connecting to: mongodb://127.0.0.1:27017
Implicit session: session { "id" : UUID("c5717a03-56b7-4d69-83cf-434a51542a49") }
MongoDB server version: 3.6.9
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
Server has startup warnings:
2018-12-13T09:48:46.928+0800 I STORAGE [initandlisten]
2018-12-13T09:48:46.928+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2018-12-13T09:48:46.928+0800 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2018-12-13T09:48:47.803+0800 I CONTROL [initandlisten]
2018-12-13T09:48:47.803+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-12-13T09:48:47.803+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-12-13T09:48:47.803+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-12-13T09:48:47.803+0800 I CONTROL [initandlisten]
2018-12-13T09:48:47.803+0800 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2018-12-13T09:48:47.803+0800 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2018-12-13T09:48:47.803+0800 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2018-12-13T09:48:47.803+0800 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2018-12-13T09:48:47.803+0800 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2018-12-13T09:48:47.803+0800 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2018-12-13T09:48:47.803+0800 I CONTROL [initandlisten]
2018-12-13T09:48:47.804+0800 I CONTROL [initandlisten]
2018-12-13T09:48:47.804+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2018-12-13T09:48:47.804+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2018-12-13T09:48:47.804+0800 I CONTROL [initandlisten]
2018-12-13T09:48:47.804+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2018-12-13T09:48:47.804+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2018-12-13T09:48:47.804+0800 I CONTROL [initandlisten]
> use DATABASE_NAME
如果數據庫不存在,則創建數據庫,否則切換到指定數據庫。
switched to db DATABASE_NAME
> use kingscc
switched to db kingscc
> show dbs
( 查看都有什么數據庫,里面沒有數據的數據庫不顯示)
admin 0.000GB
config 0.000GB
local 0.000GB
> db
(顯示當前的數據庫)
kingscc
> db.kingscc.insert({"name":"kingscc丶"}) (往數據庫插入數據)
WriteResult({ "nInserted" : 1 })
> db.dropDatabase() (首先先使用數據庫,在進行刪除)
{ "dropped" : "kingscc", "ok" : 1 }
> db 刪除當前數據庫,默認為 test,你可以使用 db 命令查看當前數據庫名。
kingscc
[END] 2018/12/13 9:55:10
看完上述內容,你們對MongoDB制定路徑登陸創建的方法是什么有進一步的了解嗎?如果還想了解更多知識或者相關內容,請關注億速云行業資訊頻道,感謝大家的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。