一、背景

原数据库数据目录:/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)

  

mysql 8.0 改变数据目录和日志目录(二)的更多相关文章

  1. mysql 8.0 改变数据目录和日志目录(一)

    一.背景 原数据库数据目录:/data/mysql3306/data,日志文件目录:/data/mysql3306/binlog 变更后数据库目录:/mysqldata/3306/data,日志文件目 ...

  2. MySQL 8.0二进制包安装

    1.官方下载 https://dev.mysql.com/downloads/mysql/ 这样就可以下载二进制包了 1.删除之前安装的MySQL包 [root@localhost ~]# rpm - ...

  3. MySQL 8.0 yum安装和配置

    MySQL 8.0 centos7.5 x86_64 一.yum安装 1.先卸载机器和mysql有关的东西,有的安装了mariab-lib,会对安装有干扰,卸载了它. [root@localhost ...

  4. linux下编译qt5.6.0静态库(使用./configure --help来看看都有哪些参数。超详细,有每一个模块的说明。如果改变了安装的目录,需要到安装目录下的bin目录下创建文件qt.conf)(乌合之众)good

    linux下编译qt5.6.0静态库 linux下编译qt5.6.0静态库 configure生成makefile 安装选项 Configure选项 第三方库: 附加选项: QNX/Blackberr ...

  5. 九、cent OS下tomcat改变日志目录

    修改catalina.out的目录bin目录下修改catalina.sh:CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out  此行内的 ...

  6. What's New In MySQL 8.0

        由于8.0内有很多C++11特性.需要gcc4.8版本以上.Rhel6系列默认gcc是4.7.在安装gcc6.1之后仍然检查不过. 原因可能是6.1版本不一定高于4.7,暂不讨论.鉴于升级gc ...

  7. MySQL 5.0的my.cnf配置选项(另外一种方式分类整理)

    一.   mysqld程序--目录和文件 basedir = path 使用给定目录作为根目录(安装目录). Show variables like “basedir”   //数据库中查看目录 da ...

  8. CentOS 7.x下安装部署MySQL 8.0实施手册

    MySQL 8 正式版 8.0.11 已发布,官方表示 MySQL 8 要比 MySQL 5.7 快 2 倍,还带来了大量的改进和更快的性能! 一.  Mysql8.0版本相比之前版本的一些特性 1) ...

  9. (4.7)mysql备份还原——深入解析二进制日志(3)binlog的三种日志记录模式详解

    关键词:binlog模式,binlog,二进制日志,binlog日志 目录概述 0.binlog概述 查看binlog日志参数设置: show variables like '%log_bin%'; ...

随机推荐

  1. 安恒DASCTF 四月战 WP

    web1 打开提就是源码审计 考点:反序列化POP链.反序列化字符串逃逸 show_source("index.php"); function write($data) { ret ...

  2. Hbase启动报java异常

    在conf文件夹下的hbase-env.sh文件中的j添加ava_home的环境变量, ******************************************************** ...

  3. 太妙了!Spring boot 整合 Mybatis Druid,还能配置监控?

    Spring boot 整合 Mybatis Druid并配置监控 添加依赖 <!--druid--> <dependency> <groupId>com.alib ...

  4. PVE简单迁移虚拟机

    工作中有2台PVE节点,但是没有做集群,如果有集群可以很方便的进行迁移.本次迁移的目的是: 目前有一台PVE1节点装的虚机资源使用较多,想迁移某台虚机到另一台PVE2. 1 备份 备份在web页面操作 ...

  5. 怎么用思维导图软件iMindMap整理发文思路

    如果你是一个普通的博客作者,那么你就应该明白在枯竭时寻找灵感就像是一场噩梦,即使你有一千个想法,但是你无法将它们关联起来也是无用的,所以,为什么不试试iMindMap思维导图呢,尝试创新,进行组建,你 ...

  6. lca(lowestCommonAncestor)

  7. Jmeter测试TCP协议

    最近做了个项目是TCP协议传输数据,于是马上想试试JMeter测试TCP. 1首先需要下载第三方的TCP插件包ApacheJMeter_tcp.jar,下载步骤请自行百度. 2.下载完重新配置jmet ...

  8. Linux中redis服务开启

    集群模式设置为no 就可以开启服务 cluster-enable no

  9. Leetcode1 - 10

    1. 两数之和 class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { ...

  10. 二:robot framework基本组成

    1.RF组成:套件.用例.关键字 套件:测试用例的集合,可以是一个模块的功能点的集合.也可以是很多模块功能点的集合 用例:一般是由多个关键字组成的 关键字:测试库.资源文件.用例所在文件的关键字表 2 ...