zoukankan      html  css  js  c++  java
  • mongodb数据库安装与卸载

    此处以centos下monggodb3.4版本安装为例,可参考官网安装教程

    步骤如下:

    1、配置mongodb ym源

    vi /etc/yum.repos.d/mongodb-org-3.4.repo

    文件内容为:

    [mongodb-org-3.4]
    name=MongoDB 3.4 Repository
    baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
    gpgcheck=0
    enabled=1

    2、执行yum安装mongodb

    yum install -y mongodb-org

    安装成功后会生成mongdb的配置文件:/etc/mongod.conf

    3、启动mongodb

    service mongod start

    4、验证mongodb启动状态

    查看mongodb日志文件,看是否有如下输出:

    [initandlisten] waiting for connections on port <port>

    mongodb 日志文件默认为/var/log/mongodb/mongod.log,可在配置文件(/etc/mongod.conf)进行修改

    5、配置开机启动

    执行如下语句:

    chkconfig mongod on

    到此mongodb安装完成

    下面介绍几个指令:

    关闭mongdb:

    service mongod stop

    重启mongodb(当修改配置文件后需要重启生效)

    service mongod restart

    客户端连接mongodb,默认情况下,mongdb监听只本地连接(127.0.0.1),默认端口为:27017

    mongo --host <ip>:<port>

    下面介绍下mongodb卸载步骤:

    1、停用mongdb服务:

    service mongod stop

    2、删除mongodb安装文件

    yum erase $(rpm -qa | grep mongodb-org)

    3、删除mongdb数据库和日志文件(具体文件目录可查看配置文件)

    rm -r /var/log/mongodb
    rm -r /var/lib/mongo

    备忘:

    spring-data-mongodb 查询记录,附上官网内容如下:

    You can use the Query and Criteria classes to express your queries. They have method names that mirror the native MongoDB operator names, such as lt, lte, is, and others. The Query and Criteria classes follow a fluent API style so that you can chain together multiple method criteria and queries while having easy-to-understand code. To improve readability, static imports let you avoid using the 'new' keyword for creating Query and Criteria instances. You can also use BasicQuery to create Query instances from plain JSON Strings, as shown in the following example:

    Example 62. Creating a Query instance from a plain JSON String

    BasicQuery query = new BasicQuery("{ age : { $lt : 50 }, accounts.balance : { $gt : 1000.00 }}");
    List<Person> result = mongoTemplate.find(query, Person.class);
  • 相关阅读:
    华硕路由器修改 Hosts 以达到局域网内自定义解析
    一款开源、高颜值的终端terminus,支持Windows、MacOS
    Windows 10启用Linux子系统(WSL)
    一款全能的下载工具Motrix,支持BT、磁力链、百度网盘等资源
    ubuntu 14.04 和16.04 快速下载
    CentOS 7一键安装Seafile搭建私有云存储
    background背景色
    3d爱心代码
    Mac Mini(late 2014) 添加NVMe固态组Fusion Drive
    member access within misaligned address 0x0000002c3931 for type 'struct ListNode‘
  • 原文地址:https://www.cnblogs.com/yinz/p/8533872.html
Copyright © 2011-2022 走看看