• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

mysql8.0.20配合binlog2sql的配置和简单备份恢复的步骤详解

mysql 搞代码 4年前 (2022-01-09) 34次浏览 已收录 0个评论

第一步 安装

 1.安装MySQL

2.安装Python3

[root@localhost /]#yum install python3

3.下载binlog2sql文件到本地(文件在百度云盘)

[root@localhost /]#mkdir tools
[root@localhost /]#cd tools
[root@localhost tools]# ll
total 317440
-rw-r--r--. 1 <div>本文来源gaodai.ma#com搞##代!^码7网</div>root root   317440 Sep 21 23:55 binlog2sql.tar
[root@localhost tools]#tar -xvf binlog2sql.tar
[root@localhost tools]#cd binlog2sql
[root@localhost binlog2sql]# ll
total 52
drwxr-xr-x. 3 mysql mysql  91 Jun 13 08:14 binlog2sql
drwxr-xr-x. 2 mysql mysql  54 Jun 13 07:45 example
-rw-r--r--. 1 mysql mysql 35141 Jun 13 07:45 LICENSE
-rw-r--r--. 1 mysql mysql 9514 Jun 13 07:45 README.md
-rw-r--r--. 1 mysql mysql  54 Jun 13 07:45 requirements.txt
drwxr-xr-x. 2 mysql mysql  37 Jun 13 07:45 tests

4.修改binlog2sql中的requirements.txt,把PyMySQL==0.7.11改为0.9.3,保存退出

[root@localhost binlog2sql]# vi requirements.txt
PyMySQL==0.9.3
wheel==0.29.0
mysql-replication==0.13

5.安装和检查,确保是0.9.3 不然出错

[root@localhost binlog2sql]# pip3 install -r requirements.txt
[root@localhost binlog2sql]# pip3 show pymysql
Name: PyMySQL
Version: 0.9.3
Summary: Pure Python MySQL Driver
Home-page: https://github.com/PyMySQL/PyMySQL/
Author: yutaka.matsubara
Author-email: [email protected]
License: "MIT"
Location: /usr/local/lib/python3.6/site-packages
Requires:

第二步 准备MySQL数据

1.配置文件最好加入安全目录secure-file-priv=/test,重启MySQL

[root@localhost /]# mkdir test
[root@localhost /]# chown -R mysql.mysql test
[root@localhost mysqldata]#vi my.cnf
secure-file-priv=/test
basedir=/application/mysql
datadir=/data/mysql
socket=/data/mysqldata/mysql.sock
log_error=/data/mysqldata/mysql8.0.err
port=3306
server_id=6
secure-file-priv=/test
autocommit=0 
log_bin=/data/mysqldata/mysql-bin 
[root@localhost mysqldata]# systemctl start mysqld

注:每个人都配置文件路径都不一样

2.进入MySQL

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.20 MySQL Community Server - GPL

Copyright (c) 2000, 2020, 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 master status\g;
+------------------+----------+--------------+------------------+-------------------+
| File       | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 |   156 |       |         |          |
+------------------+----------+--------------+------------------+-------------------+

mysql> create database csdn;
mysql> use csdn
mysql> insert into t1 values(1),(2),(3),(4),(5),(6),(7),(8);
mysql> commit;
mysql> update t1 set id=10 where id=1;
mysql> delete from t1 where id=3;
mysql> commit;

第三步 测试 进入binlog2sql目录下的binlog2sql下

[root@localhost binlog2sql]# pwd
/tools/binlog2sql/binlog2sql
[root@localhost binlog2sql]# ll
total 24
-rwxr-xr-x. 1 mysql mysql 7747 Jun 13 07:45 binlog2sql.py
-rwxr-xr-x. 1 mysql mysql 11581 Jun 13 07:45 binlog2sql_util.py
-rw-r--r--. 1 mysql mysql  92 Jun 13 07:45 __init__.py
drwxr-xr-x. 2 mysql mysql  44 Jun 13 07:50 __pycache__

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:mysql8.0.20配合binlog2sql的配置和简单备份恢复的步骤详解

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址