zoukankan      html  css  js  c++  java
  • mysql 8.0 改变数据目录和日志目录(一)

    一、背景
    
    原数据库数据目录:/data/mysql3306/data,日志文件目录:/data/mysql3306/binlog
    
    变更后数据库目录:/mysqldata/3306/data,日志文件目录:/mysqldata/3306/binlog
    
     
    
    二、操作过程
    
    1、停止原库
    
    [root@node01 ~]# /etc/init.d/mysqld stop
    Shutting down MySQL.. SUCCESS!
    
    2、拷贝数据目录
    
    [root@node01 ~]# cp -a /data/mysql3306/data/* /mysqldata/3306/data/
    
    3、修改参数文件
    
    原参数文件:
    
    [client]
    port=3306
    socket=/tmp/mysql.sock
    
    [mysqld]
    port=3306
    user=mysql
    server_id=1
    socket=/tmp/mysql.sock
    basedir=/usr/local/mysql
    datadir=/data/mysql3306/data
    log-error=/data/mysql3306/data/error.log
    log_bin=/data/mysql3306/binlog/mysql-bin
    gtid_mode=ON
    enforce_gtid_consistency=ON
    log_slave_updates=1
    
     
    
    修改后参数文件:
    
    [client]
    port=3306
    socket=/tmp/mysql.sock
    
    [mysqld]
    port=3306
    user=mysql
    server_id=1
    socket=/tmp/mysql.sock
    basedir=/usr/local/mysql
    datadir=/mysqldata/3306/data
    log-error=/mysqldata/3306/data/error.log
    log_bin=/mysqldata/3306/binlog/mysql-bin
    gtid_mode=ON
    enforce_gtid_consistency=ON
    log_slave_updates=1
    
     
    
    4、启动数据库
    
    [root@node01 ~]# /etc/init.d/mysqld start
    Starting MySQL... SUCCESS!
    
     
    
    三、登录数据库验证
    mysql> show variables like 'datadir';
    +---------------+-----------------------+
    | Variable_name | Value                 |
    +---------------+-----------------------+
    | datadir       | /mysqldata/3306/data/ |
    +---------------+-----------------------+
    1 row in set (0.00 sec)
    
    mysql> show variables like '%log_bin%';
    +---------------------------------+----------------------------------------+
    | Variable_name                   | Value                                  |
    +---------------------------------+----------------------------------------+
    | log_bin                         | ON                                     |
    | log_bin_basename                | /mysqldata/3306/binlog/mysql-bin       |
    | log_bin_index                   | /mysqldata/3306/binlog/mysql-bin.index |
    | log_bin_trust_function_creators | OFF                                    |
    | log_bin_use_v1_row_events       | OFF                                    |
    | sql_log_bin                     | ON                                     |
    +---------------------------------+----------------------------------------+
    6 rows in set (0.01 sec)
    
     
      
    

      

  • 相关阅读:
    运行级别和root密码找回
    磁盘情况查询
    linux磁盘分区、挂载
    三、本地负载均衡器与openfeign声明式客户端
    二、Nacos服务注册与发现
    一、微服务架构演变过程
    shell工具
    Netty概述
    垃圾回收概述及算法
    执行引擎
  • 原文地址:https://www.cnblogs.com/orcl-2018/p/13734243.html
Copyright © 2011-2022 走看看