暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

mysql数据备份后在异平台还原

原创 风车 2022-12-29
401
mysqlbackup --defaults-file=/etc/my.cnf  --user=root --password=Passw0rd   --with-timestamp   --backup-dir=/data/backup   --socket=/mysql/tmp/mysqld.sock backup

2.打包备份:

tar -zcvf mysqlbackup .tar.gz ./mysqlbackup/*

3.备份拷贝至window平台下:

4.下载对应版本window平台下MySQL解压安装包:

解压到相应目录

5.切换到D:\mysql-5.7.23目录下,参考linux my.cnf 编辑调整my.ini

vi my.ini ###搭建主从复制环境,注意调整server-id

[mysqld]
basedir = D:\mysql-5.7.23
datadir = D:\mysql-5.7.23\data
socket = D:\mysql-5.7.23/mysqld.sock
user = mysql
max_connections=1000
port = 3306
character_set_server = utf8
local-infile=0
symbolic-links = 0
gtid-mode = on
enforce-gtid-consistency = 1
default-storage-engine = INNODB
innodb_buffer_pool_size=20480M
innodb_buffer_pool_instances=10
innodb_thread_concurrency=24
innodb_flush_neighbors=1
innodb_data_home_dir = D:\mysql-5.7.23\data
innodb_data_file_path = ibdata1:1G:autoextend
innodb_log_group_home_dir = D:\mysql-5.7.23\data
innodb_log_file_size=512M
innodb_log_files_in_group=4
innodb_file_per_table=1
innodb_log_buffer_size=64M

log-bin=D:\mysql-5.7.23\data\mysql-bin
expire_logs_days = 14
max_binlog_size = 500M
sync_binlog=0
binlog_format=row
relay-log=mysql-relay
server-id=12
innodb_flush_log_at_trx_commit=1
log_timestamps=system

sql_mode=''


[mysqld_safe]
log-error = D:\mysql-5.7.23\mysql-error.log
pid-file = D:\mysql-5.7.23\mysql.pid

[mysql]
port = 3306
socket = D:\mysql-5.7.23\mysqld.sock
prompt = [\\u@\\h][\\d]>\\_

5.新建文件夹data,执行恢复操作:

mysqlbackup --defaults-file=D:\mysql-5.7.23\my.ini --backup-dir=D:\mysqlbackup    apply-log
mysqlbackup --defaults-file=D:\mysql-5.7.23\my.ini --backup-dir=D:\mysqlbackup    copy-back

6.安装MySQL服务并启动登录验证

cd /d D:\mysql-5.7.23\bin

D:\mysql-5.7.23\bin>mysqld -install
Service successfully installed.

net start mysql
net start mysql

MySQL 服务正在启动 …
MySQL 服务已经启动成功。

D:\mysql-5.7.23\bin>mysql -uroot -p xxxxx
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.23-log MySQL Community Server (GPL)

Copyright © 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.

[root@localhost][(none)]> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| db |
| mysql |
| performance_schema |
| sys |
| test |
±-------------------+
6 rows in set (0.02 sec)

[root@localhost][(none)]>

注:
相同版本忽略下面步骤

启动
net start msyql

升级
mysql:

cd /d D:\mysql-5.7.23\bin
mysql_upgrade -uroot -pxxxxxxx  --port=3306

重启

net stop mysql
net start mysql
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论