多实例部署、开机自启、xtrabackup备份与恢复

本文详细介绍了如何在CentOS8系统上部署多个MySQL实例,包括下载软件、创建用户和组、配置环境变量、初始化实例等步骤。同时,讲解了配置开机自启动服务的方法,并展示了使用xtrabackup进行数据库备份和恢复的过程,包括备份文件的验证、增量备份和恢复操作。
摘要由CSDN通过智能技术生成

多实例部署、开机自启、xtrabackup备份与回复

mysql多实例部署

1.软件下载

下载二进制格式的mysql软件包

[root@centos8-1 ~]# cd /usr/src
[root@centos8-1 src]# wget http://https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
[root@centos8-1 src]# ls
debug
kernels
mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
[root@centos8-1 src]# 

解压包到/usr/local/目录下面

[root@centos8-1 src]# tar -xf mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@centos8-1 src]# ls /usr/local/
bin      libexec
etc      mysql-5.7.35-linux-glibc2.12-x86_64
games    sbin
include  share
lib      src
lib64
[root@centos8-1 src]# 

创建用户和组

如果创建了用户和组就不用创建了

[root@centos8-1 src]# groupadd -r mysql
groupadd:“mysql”组已存在
[root@centos8-1 src]# useradd -M -s /sbin/nologin -g mysql mysql
useradd:用户“mysql”已存在
[root@centos8-1 src]# 

创建软连接

[root@centos8-1 local]# ln -s mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz 
[root@centos8-1 local]# ll
总用量 0
drwxr-xr-x. 2 root root   6 5月  18 2020 bin
drwxr-xr-x. 2 root root   6 5月  18 2020 etc
drwxr-xr-x. 2 root root   6 5月  18 2020 games
drwxr-xr-x. 2 root root   6 5月  18 2020 include
drwxr-xr-x. 2 root root   6 5月  18 2020 lib
drwxr-xr-x. 3 root root  17 7月  13 02:27 lib64
drwxr-xr-x. 2 root root   6 5月  18 2020 libexec
drwxr-xr-x. 9 root root 129 8月  29 08:16 mysql-5.7.35-linux-glibc2.12-x86_64
lrwxrwxrwx. 1 root root  42 8月  29 08:22 mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz -> mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
drwxr-xr-x. 2 root root   6 5月  18 2020 sbin
drwxr-xr-x. 5 root root  49 7月  13 02:27 share
drwxr-xr-x. 2 root root   6 5月  18 2020 src
[root@centos8-1 local]# 

修改属主属组

[root@centos8-1 local]# chown -R mysql.mysql mysql*
[root@centos8-1 local]# ll
总用量 0
drwxr-xr-x. 2 root  root    6 5月  18 2020 bin
drwxr-xr-x. 2 root  root    6 5月  18 2020 etc
drwxr-xr-x. 2 root  root    6 5月  18 2020 games
drwxr-xr-x. 2 root  root    6 5月  18 2020 include
drwxr-xr-x. 2 root  root    6 5月  18 2020 lib
drwxr-xr-x. 3 root  root   17 7月  13 02:27 lib64
drwxr-xr-x. 2 root  root    6 5月  18 2020 libexec
drwxr-xr-x. 9 mysql mysql 129 8月  29 08:16 mysql-5.7.35-linux-glibc2.12-x86_64
lrwxrwxrwx. 1 mysql mysql  42 8月  29 08:22 mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz -> mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
drwxr-xr-x. 2 root  root    6 5月  18 2020 sbin
drwxr-xr-x. 5 root  root   49 7月  13 02:27 share
drwxr-xr-x. 2 root  root    6 5月  18 2020 src
[root@centos8-1 local]# 

配置环境变量

[root@centos8-1 local]# echo "export PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh
[root@centos8-1 local]# which mysql
/usr/bin/mysql
[root@centos8-1 local]# source /etc/profile.d/mysql.sh 
[root@centos8-1 local]# 

创建个实例数据存放的目录

[root@centos8-1 opt]# mkdir -p /opt/data/{3306,3307,3308}
[root@centos8-1 opt]# ls /opt/data/
3306  3307  3308
[root@centos8-1 opt]# 
[root@centos8-1 opt]#  chown mysql.mysql /opt/data/{3306,3307,3308}
[root@centos8-1 opt]# ll data/
总用量 0
drwxr-xr-x. 2 mysql mysql 6 8月  29 08:27 3306
drwxr-xr-x. 2 mysql mysql 6 8月  29 08:27 3307
drwxr-xr-x. 2 mysql mysql 6 8月  29 08:27 3308
[root@centos8-1 opt]# 

初始化实例

初始化3306

[root@localhost ~]# mysqld --initialize --user mysql --datadir /opt/data/3306
2021-08-27T12:09:43.957362Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-08-27T12:09:45.070984Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-08-27T12:09:45.259869Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-08-27T12:09:45.368131Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: aae5b407-072f-11ec-8cb9-000c2978b180.
2021-08-27T12:09:45.371548Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-08-27T12:09:46.251041Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2021-08-27T12:09:46.251061Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2021-08-27T12:09:46.252075Z 0 [Warning] CA certificate ca.pem is self signed.
2021-08-27T12:09:47.105510Z 1 [Note] A temporary password is generated for root@localhost: tdX-*ey)Y1_a
[root@localhost ~]# echo 'tdX-*ey)Y1_a' > 3306_pass
[root@localhost ~]# ls
3306_pass  anaconda-ks.cfg  mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
[root@localhost ~]# cat 3306_pass 
tdX-*ey)Y1_a

初始化3307

[root@localhost ~]# mysqld --initialize --user mysql --datadir /opt/data/3307
2021-08-27T12:10:22.121228Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-08-27T12:10:23.371094Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-08-27T12:10:23.551015Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-08-27T12:10:23.988171Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: c1eaa7e8-072f-11ec-8eee-000c2978b180.
2021-08-27T12:10:23.991268Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-08-27T12:10:25.006022Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2021-08-27T12:10:25.006044Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2021-08-27T12:10:25.014096Z 0 [Warning] CA certificate ca.pem is self signed.
2021-08-27T12:10:25.139118Z 1 [Note] A temporary password is generated for root@localhost: OpCs&?ILf0z)
[root@localhost ~]# echo 'OpCs%$sLf0z)' > 3307_pass
[root@localhost ~]# cat 3307_pass
OpCs%$sLf0z)

初始化3308

[root@localhost ~]# mysqld --initialize --user mysql --datadir /opt/data/3308
2021-08-27T12:11:08.680649Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-08-27T12:11:10.064525Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-08-27T12:11:10.267492Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-08-27T12:11:10.356165Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: dd8ddb31-072f-11ec-9185-000c2978b180.
2021-08-27T12:11:10.357696Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-08-27T12:11:11.694578Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2021-08-27T12:11:11.694596Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2021-08-27T12:11:11.695690Z 0 [Warning] CA certificate ca.pem is self signed.
2021-08-27T12:11:12.272690Z 1 [Note] A temporary password is generated for root@localhost: nGpdhZUu;48q
[root@localhost~]# echo 'nGfjkeZUu;48q' > 3308_pass
[root@localhost~]# cat 3308_pass
nGfjkeZUu;48q

安装perl

[root@centos8-1 ~]# yum -y install perl
上次元数据过期检查:0:09:57 前,执行于 2021年08月29日 星期日 08时32分29秒。
依赖关系解决。
=================================================
 软件包
       架构   版本               仓库       大小
=================================================
安装:

查看是否缺少依赖包

[root@localhost ~]# ldd /usr/local/mysql/bin/mysql  //lld查某一个程序文件它所依赖的包
	linux-vdso.so.1 =>  (0x00007ffecdbfb000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f543b00b000)
	librt.so.1 => /lib64/librt.so.1 (0x00007f543ae03000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f543abff000)
	libncurses.so.5 => /lib64/libncurses.so.5 (0x00007f543a9d8000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f543a6d0000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f543a3ce000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f543a1b8000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f5439deb000)
	libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007f5439bc1000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f543b227000

配置/etc/my.cnf

[root@localhost ~]# vim /etc/my.cnf
[root@localhost ~]# cat /etc/my.cnf
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin


[mysqld3306]
datadir = /opt/data/3306
port = 3306
socket = /tmp/3306.sock
pid-file = /opt/date/3306/mysql.pid
log-error = /var/log/mysql_3306.log

[mysqld3307]
datadir = /opt/data/3307
port = 3307
socket = /tmp/3307.sock
pid-file = /opt/date/3307/mysql.pid
log-error = /var/log/mysql_3307.log

[mysqld3308]
datadir = /opt/data/3308
port = 3308
socket = /tmp/3308.sock
pid-file = /opt/date/3308/mysql.pid
log-error = /var/log/mysql_3308.log

启动实例

[root@localhost ~]# mysqld_multi start 3336
[root@localhost ~]# ss -anlt
State      Recv-Q Send-Q     Local Address:Port                    Peer Address:Port
LISTEN     0      128                    *:22                                 *:*
LISTEN     0      100            127.0.0.1:25                                 *:*
LISTEN     0      80                    :::3307                              :::*
LISTEN     0      80                    :::3308                              :::*
LISTEN     0      128                   :::22                                :::*
LISTEN     0      100                  ::1:25                                :::*
LISTEN     0      80                    :::3306                              :::*

修改密码

[root@localhost ~]# ls /opt/data
3306_pass  3307_pass  3308_pass  anaconda-ks.cfg
[root@localhost ~]# cat 3306_pass
gKRe:h._asdkg
[root@localhost ~]# mysql -uroot -p'gKRe:h._asdkg' -h127.0.0.1 -h3306
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.22

Copyright (c) 2000, 2018, 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> set password = password('shen');
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> quit
Bye


[root@localhost ~]# cat 3307_pass 
hSf,.Ser.wr2

[root@localhost ~]# mysql -uroot -phSf,.Ser.wr2 -h127.0.0.1 -p3307
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.22

Copyright (c) 2000, 2018, 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> set password = password('shen');
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> quit
Bye


[root@localhost ~]# cat 3308_pass 
rXumdfgt(5;D

[root@localhost ~]# mysql -uroot -p'rXumdcfgt(5;D' -h127.0.0.1 -P3308
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.35

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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> set password = password('shen');
Query OK, 0 rows affected, 1 warning (0.00 sec)

验证

[root@localhost ~]# mysql -uroot -pshen -h127.0.0.1 -P3306
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.7.35 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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> 

2.开机自启动

将服务文件copy到init.d下,并命名为mysqld

[root@localhost ~]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost ~]# echo export PATH=/usr/local/mysql/bin:$PATH > /etc/init.d/mysqld

给可执行权限

[root@localhost ~]# chmod +x /etc/init.d/mysqld

添加服务

[root@localhost ~]# chkconfig --add mysqld

启动

[root@localhost ~]# service mysqld_multi start
[root@localhost ~]# ss -antl 
State  Recv-Q Send-Q  Local Address:Port   Peer Address:Port                                                    
LISTEN 0      128           0.0.0.0:22          0.0.0.0:*                                                       
LISTEN 0      80                  :::3306              :::*                                                       
LISTEN 0      128              [::]:22             [::]:*

LISTEN 0      80                  ::::3307              :::*

LISTEN 0      80                  :::3308              :::*

ISTEN  0      100              127.0.0.1:25           *:*

3.xtrabackup备份与恢复

介绍

MySQL冷备、mysqldump、MySQL热拷贝都无法实现对数据库进行增量备份。在实际生产环境中增量备份是非常实用的,如果数据大于50G或100G,存储空间足够的情况下,可以每天进行完整备份,如果每天产生的数据量较大,需要定制数据备份策略。例如每周实用完整备份,周一到周六实用增量备份。而Percona-Xtrabackup就是为了实现增量备份而出现的一款主流备份工具,xtrabakackup有2个工具,分别是xtrabakup、innobakupe。

Percona-xtrabackup是 Percona公司开发的一个用于MySQL数据库物理热备的备份工具,支持MySQL、Percona server和MariaDB,开源免费,是目前较为受欢迎的主流备份工具。xtrabackup只能备份innoDB和xtraDB两种数据引擎的表,而不能备份MyISAM数据表
优点:

(1)备份速度快,物理备份可靠

(2)备份过程不会打断正在执行的事务(无需锁表)

(3)能够基于压缩等功能节约磁盘空间和流量

(4)自动备份校验

(5)还原速度快

(6)可以流传将备份传输到另外一台机器上

(7)在不增加服务器负载的情况备份数据

语法:

  • –defaults-file=/etc/my.cnf 指定mysql的配置文件my.cfg,如果指定则必须是第一个参数。
  • –defaults-file=/etc/my.cnf 指定mysql的配置文件my.cfg,如果指定则必须是第一个参数。

注意:备份时需启动MySQL,恢复时需关闭MySQL,清空mysql数据目录且不能重新初始化,恢复数据后应该立即进行一次完全备份

安装

[root@localhost ~]# wget https://repo.percona.com/yum/release/7/RPMS/x86_64/percona-xtrabackup-2.3.10-1.el7.x86_64.rpm

[root@localhost ~]# yum -y install percona-xtrabackup-2.3.10-1.el7.x86_64.rpm 
已加载插件:fastestmirror
正在检查 percona-xtrabackup-2.3.10-1.el7.x86_64.rpm: percona-xtrabackup-2.3.10-1.el7.x86_64
percona-xtrabackup-2.3.10-1.el7.x86_64.rpm 将被安装
正在解决依赖关系
--> 正在检查事务
.......
[root@localhost ~]# rpm -qa |grep xtrabackup
percona-xtrabackup-2.3.10-1.el7.x86_64

实例

创建备份目录

[root@centos8-1 ~]# mkdir mysqkvackup
[root@centos8-1 ~]# ls
anaconda-ks.cfg  mysqkvackup  mysqldump
[root@centos8-1 ~]# cd mysqkvackup/
[root@centos8-1 mysqkvackup]# 

备份

[root@localhost ~]# innobackupex --user=root--password=shen  mysqkvackup/

MySQL binlog position:filename 'mysql-bin.000004', position '107'

210829 21:03:23 [00]Writing backup-my.cnf

210829  21:03:23 [00]        ...done

210829 21:03:23 [00]Writing xtrabackup_info

210829  21:03:23 [00]        ...done

xtrabackup: Transactionlog of lsn (1595675) to (1595675) was copied.

210829  21:03:24 completedOK!

查看刚刚备份的文件

[root@localhost ~]# ls   mysqkvackup

2021-08-29_21-03-06

[root@localhost ~]# ls mysqkvackup/2021-08-29_21-03-06/

backup-my.cnf  mysql               xtrabackup_binlog_info  xtrabackup_info

ibdata1        performance_schema  xtrabackup_checkpoints  xtrabackup_logfile

查看日志的位置

[root@localhost ~]# cat  mysqkvackup/2021-08-27_21-03-06/xtrabackup_binlog_info

mysql-bin.000004   107

登录数据库

[root@localhost ~]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.35

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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 shen;

Query OK, 1 row affected(0.00 sec)

 

mysql> use shen;

Database changed

mysql> create table long (id int,name char(16) not null);

Query OK, 0 rows affected(0.05 sec)

 

mysql> insert into long values(1,'fei');

Query OK, 1 row affected(0.02 sec)

 

mysql> insert into long values(2,'shuaige');

Query OK, 1 row affected(0.02 sec)

 

mysql> select * from long;

+------+----------+

| id   | name    |

+------+----------+

|    1 | fei |

|    2 | shuaige    |

+------+----------+

2 rows in set (0.00 sec)

mysql> exit

Bye

增量备份二进制文件

[root@localhost ~]# mysqlbinlog --start-position=107 /usr/local/mysql/data/mysql-bin.000004> mysqkvackup/`date +%F`.sql

[root@localhost ~]# ls mysqkvackup

2021-08-27.sql    2021-08-29_21-03-06

模拟数据库被损坏

[root@localhost ~]# mv /usr/local/mysql/data/*  /opt/

一般在备份完成后,数据尚且不能用于恢复操作,因为备份的数据中可能会包含尚未提交的事务或已经提交但尚未同步至数据文件中的事务。因此,此时数据文件仍处于不一致状态。“准备”的主要作用正是通过回滚未提交的事务及同步已经提交的事务至数据文件也使得数据文件处于一致性状态。

在准备(prepare)过程结束后,InnoDB表数据已经前滚到整个备份结束的点,而不是回滚到xtrabackup刚开始时的点。
innobakupex命令的–apply-log选项可用于实现上面的功能

[root@localhost ~]# innobackupex --apply-log/mysqkvackup/2021-08-27_21-03-06/

.........

InnoDB: File './ibtmp1'size is now 12 MB.

InnoDB: 96 redo rollbacksegment(s) found. 1 redo rollback segment(s) are active.

InnoDB: 32 non-redorollback segment(s) are active.

InnoDB: 5.7.13 started;log sequence number 1595925

xtrabackup: startingshutdown with innodb_fast_shutdown = 1

InnoDB: FTS optimizethread exiting.

InnoDB: Startingshutdown...

InnoDB: Shutdowncompleted; log sequence number 1595944

210827 21:33:32 completedOK!

使用innobakupex命令的 --copy-back 进行拷贝

[root@localhost ~]# innobackupex --copy-back/mysqkvackup/2021-08-27_21-03-06/

...........

210827 21:36:07 [01]        ...done

210827 21:36:07 [01]Copying ./performance_schema/events_waits_current.frm to/usr/local/mysql/data/performance_schema/events_waits_current.frm

210827 21:36:07 [01]        ...done

210827 21:36:07 completedOK!

查看

root@localhost ~]# ll /usr/local/mysql/data/

总用量 40972

-rw-r-----. 1 root root18874368 8月  27 21:36 ibdata1

-rw-r-----. 1 rootroot  5242880 8月  27 21:36 ib_logfile0

-rw-r-----. 1 rootroot  5242880 8月  2721:36 ib_logfile1

-rw-r-----. 1 root root12582912 8月  27 21:36 ibtmp1

drwxr-x---. 2 rootroot     4096 8月  27 21:36 mysql

drwxr-x---. 2 rootroot     4096 8月  27 21:36 performance_schema

-rw-r-----. 1 rootroot      478 8月  27 21:36 xtrabackup_info
//修改属主属组
[root@localhost ~]# chown -R mysql:mysql/usr/local/mysql/data/
//kill 掉mysql 的进程
[root@localhost ~]# killall mysqld
//重启
[root@localhost ~]# service mysqld start

Starting MySQL..                                           [确定]

登录

[root@localhost ~]# mysql -uroot -p

Enter password:

Welcome to the MySQLmonitor.  Commands end with ; or \g.

Your MySQL connection idis 1

Server version: 5.5.22-logSource distribution

 

Copyright (c) 2000, 2011,Oracle and/or its affiliates. All rights reserved.

 

Oracle is a registeredtrademark of Oracle Corporation and/or its

affiliates. Other namesmay be trademarks of their respective

owners.

 

Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.

 

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

+--------------------+

3 rows in set (0.01 sec)

关闭二进制日志

mysql> set sql_log_bin=0;

Query OK, 0 rows affected(0.00 sec)

//读取备份文件
mysql> source /opt/mysqlbackup/2021-08-27.sql

Query OK, 0 rows affected(0.00 sec)

 

Query OK, 0 rows affected(0.00 sec)

 

Query OK, 0 rows affected(0.00 sec)

 

Query OK, 0 rows affected (0.00sec)

mysql> set sql_log_bin=1;

Query OK, 0 rows affected(0.00 sec)
mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| shen              |

| mysql              |

| performance_schema |

+--------------------+

4 rows in set (0.00 sec)
mysql> use shen

Database changed

mysql> select * from long;

+------+----------+

| id   | name    |

+------+----------+

|    1 | fei |

|    2 | shuaige    |

+------+----------+

2 rows in set (0.01 sec)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Lfei5120

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值