zoukankan      html  css  js  c++  java
  • Ubuntu下mongodb的安装与使用

    mongodb的安装:

    1.MongoDB 源码下载地址:https://www.mongodb.com/download-center#community



    2.vim /etc/profile修改环境变量:末尾添加

    export PATH=$PATH:/home/no4/mongodb/bin


    3.source /etc/profile

    避免每次都要使用source /etc/profile使环境变量文件生效的方法:

        sudo su
        vim ~/.bashrc

     
    末尾添加source /etc/profile

    4.新建配置文件mongod.conf

        systemLog:
            destination: file
            path: "/home/no4/mongodata/log/mongod.log"
            logAppend: true
        storage:
            dbPath: "/home/no4/mongodata/db"
            journal:
               enabled: true
        processManagement:
            fork: true
        net:
            bindIp: localhost
            port: 27017
    



    5.在配置文件所指定的位置建立对应的文件夹

    6.mongod -f /home/no4/mongodb/mongod.conf命令启动mongodb服务器,正常输出如下:

        root@no4-Default-string:/home/no4# mongod -f ./mongodb/mongod.conf
        about to fork child process, waiting until server is ready for connections.
        forked process: 11330
        child process started successfully, parent exiting


    如果是这样:

        root@no4-Default-string:/home/no4# mongod -f ./mongodb/mongod.conf
        about to fork child process, waiting until server is ready for connections.
        forked process: 11306
        ERROR: child process failed, exited with 48
        To see additional information in this output, start without the "--fork" option.

     

    一般是因为之前已经启动过了mongodb,使用ps -ef|grep mongod查找mongod相关进程,然后杀掉后再重试。

    7.输入mongo连接服务器,再输入show dbs查看数据库,正常输出如下:

        > show dbs
        admin   0.000GB
        config  0.000GB
        local   0.000GB

     

    原文链接:https://blog.csdn.net/wangzhidi/article/details/114261049

  • 相关阅读:
    [Javascript]史上最短的IE浏览器判断代码
    初学者必看:精心整理的Javascript操作JSON总结
    用实例一步步教你写Jquery插件
    学习一种新编程语言要做的14个练习
    一些实战中总结的 javascript 开发经验
    JavaScript开发规范
    jQuery性能优化
    不到30行JS代码实现的Excel表格
    javascript 执行顺序详解
    Java基础知识强化之IO流笔记58:内存操作流
  • 原文地址:https://www.cnblogs.com/liweikuan/p/15001949.html
Copyright © 2011-2022 走看看