ITPub博客

首页 > 数据库 > 数据库开发技术 > MongoDB 制定路径登陆创建方法

MongoDB 制定路径登陆创建方法

原创 数据库开发技术 作者:s相濡以沫y 时间:2018-12-13 10:20:39 0 删除 编辑

1.下载mongodb的系统包  

wget

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

Questions? Try the support group

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

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


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31562969/viewspace-2285090/,如需转载,请注明出处,否则将追究法律责任。

上一篇: OMF
下一篇: oracle 闪回技术
请登录后发表评论 登录
全部评论

注册时间:2018-11-20

  • 博文量
    28
  • 访问量
    39405