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

    一、背景
    
    原数据库数据目录:/data/mysql3306/data,日志文件目录:/data/mysql3306/binlog
    
    变更后数据库目录:/mysqldata/3306/data,日志文件目录:/mysqldata/3306/binlog
    
     
    
    二、操作过程
    
    1、创建测试数据,并停止原库
    [root@node02 data]# mysql -uroot
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 10
    Server version: 8.0.18 MySQL Community Server - GPL
    
    Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> create database testdb;
    Query OK, 1 row affected (0.08 sec)
    
    mysql> use testdb;
    Database changed
    mysql> create table test (id int);
    Query OK, 0 rows affected (0.12 sec)
    
    mysql> insert into test values (10);
    Query OK, 1 row affected (0.18 sec)
    
    mysql> use testdb;
    Database changed
    mysql> show tables;
    +------------------+
    | Tables_in_testdb |
    +------------------+
    | test             |
    +------------------+
    1 row in set (0.01 sec)
    
    mysql> select * from test;
    +------+
    | id   |
    +------+
    |   10 |
    +------+
    1 row in set (0.00 sec)
    
    [root@node02 data]# /etc/init.d/mysqld stop
    Shutting down MySQL.. SUCCESS!
    
    2、拷贝数据目录
    
    [root@node02 data]# cp -a /data/mysql3306/data/testdb* /mysqldata/3306/data/
    [root@node02 data]# cp -a /data/mysql3306/data/mysql* /mysqldata/3306/data/
    [root@node02 data]# cp -a /data/mysql3306/data/ibdata1 /mysqldata/3306/data/
    
    3、修改参数文件
    
    原参数文件:
    
    [client]
    port=3306
    socket=/tmp/mysql.sock
    
    [mysqld]
    port=3306
    user=mysql
    server_id=2
    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=2
    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@node02 data]# /etc/init.d/mysqld start
    Starting MySQL.Logging to '/mysqldata/3306/data/error.log'.
    .. SUCCESS!
    
     
    
    三、登录数据库验证
    
    [root@node02 data]# mysql -uroot
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 8
    Server version: 8.0.18 MySQL Community Server - GPL
    
    Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> show variables like 'datadir';
    +---------------+-----------------------+
    | Variable_name | Value                 |
    +---------------+-----------------------+
    | datadir       | /mysqldata/3306/data/ |
    +---------------+-----------------------+
    1 row in set (0.11 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.00 sec)
    
    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    | testdb             |
    +--------------------+
    5 rows in set (0.01 sec)
    
    mysql> use testdb;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed
    mysql> show tables;
    +------------------+
    | Tables_in_testdb |
    +------------------+
    | test             |
    +------------------+
    1 row in set (0.00 sec)
    
    mysql> select * from test;
    +------+
    | id   |
    +------+
    |   10 |
    +------+
    1 row in set (0.00 sec)
    

      

  • 相关阅读:
    JS中offsetTop、clientTop、scrollTop、offsetTop各属性介绍
    在MOSS中使用无刷新的日历日程控件
    VCalendar不错的开源日历项目
    非常适用的Exchange 2007 Web Services
    在C#中实现DateDiff功能
    Div被Select挡住的解决办法
    安装Project Server2007出现错误
    vs2005中调试js(转)
    CrystalReports在MOSS下的新问题:来自磁盘上的图片不能显示
    关于多级审批工作流的问题描述
  • 原文地址:https://www.cnblogs.com/orcl-2018/p/13734425.html
Copyright © 2011-2022 走看看