使用Xb文件恢复msyql ubuntu18 mysql5.7

下载ubuntu 18

下载18.04 

安装 vmBox 建议文件大小为40g ,第一次还原 由于存储不够导致,后期又新创建40g

安装数据库   下载对应版本mysql

 wget https://cdn.mysql.com/archives/mysql-5.7/mysql-server_5.7.35-1ubuntu18.04_amd64.deb-bundle.tar
 apt --fix-broken install
 tar -xvf mysql-server_5.7.35-1ubuntu18.04_amd64.deb-bundle.tar 
 dpkg -i mysql-common_5.7.35-1ubuntu18.04_amd64.deb
 dpkg -i libmysqlclient20_5.7.35-1ubuntu18.04_amd64.deb 
 dpkg -i libmysqld-dev_5.7.35-1ubuntu18.04_amd64.deb 
 dpkg -i mysql-community-client_5.7.35-1ubuntu18.04_amd64.deb 
 dpkg -i mysql-client_5.7.35-1ubuntu18.04_amd64.deb
 dpkg -i mysql-community-source_5.7.35-1ubuntu18.04_amd64.deb 
 dpkg -i mysql-community-server_5.7.35-1ubuntu18.04_amd64.deb
 service mysql  status
 service mysql stop 
 service mysql  start
 service mysql  status 
 rm -rf *.deb

下载安装  percona-release_latest.bionic_all.deb

wget https://repo.percona.com/apt/percona-release_latest.bionic_all.deb
sudo dpkg -i percona-release_latest.bionic_all.deb 
apt-get update
sudo apt-get install percona-xtrabackup-24

建议安装rz 命令 代替ftp工具  实际场景还要看实际情况

下载安装 qpress下载  安装配置

tar -xf qpress-11-linux-x64.tar -C /usr/local/bin
source /etc/profile

rz 上传备份  xb 文件 

#解包备份文件
xbstream -x --parallel=2  -C /data/mysql < /data/test.xb
#解压备份文件
xtrabackup --decompress --target-dir=/data/mysql


#/data/mysql为之前存储备份文件的目标目录 ,您可根据实际情况替换为实际路径。
#Percona Xtrabackup 在2.4.6及以上版本中才支持--remove-original选项。
#xtrabackup默认在解压缩时不删除原始的压缩文件,若需解压完删除原始的压缩文件,可在上面的命令中加上--#remove-original参数。

还原数据

xtrabackup --prepare  --target-dir=/data/mysql

显示如图表示成功

 修改配置文件

vim /data/mysql/backup-my.cnf

由于存在的版本问题,请将解压文件backup-my.cnf中如下参数进行注释。

  • innodb_checksum_algorithm
  • innodb_log_checksum_algorithm
  • innodb_fast_checksum
  • innodb_page_size
  • innodb_log_block_size
  • redo_log_version
# This MySQL options file was generated by innobackupex.

# The MySQL server
[mysqld]
#innodb_checksum_algorithm=crc32
#innodb_log_checksum_algorithm=strict_crc32
innodb_data_file_path=ibdata1:12M:autoextend
innodb_log_files_in_group=4
innodb_log_file_size=1048576000
#innodb_fast_checksum=false
#innodb_page_size=16384
#innodb_log_block_size=512
innodb_undo_directory=./
innodb_undo_tablespaces=0
server_id=0
#redo_log_version=1
#server_uuid=76b51740-c209-11eb-a35028492ee0
#master_key_id=0
#innodb_fast_checksum=false

 关闭服务 清除之前 msyql目录 建文件拷贝到原mysql/data地址

 service mysql stop

更改文件权限 

chown -R mysql:mysql /data/mysql

启动恢复

mysqld_safe --defaults-file=/data/mysql/backup-my.cnf --user=mysql --datadir=/data/mysql &
root@luke-VirtualBox:/var/lib/mysql# mysqld_safe --defaults-file=/var/lib/mysql/backup-my.cnf --user=mysql --datadir=/var/lib/mysql &
[1] 7017
root@luke-VirtualBox:/var/lib/mysql# 2021-12-10T01:52:14.475803Z mysqld_safe Logging to '/var/lib/mysql/luke-VirtualBox.err'.
2021-12-10T01:52:14.487296Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

操作时可以新开一个窗口查看日志  /var/lib/mysql/luke-VirtualBox.err

mysql 安装后默认配置文件

/etc/mysql/mysql.conf.d/mysqld.cnf

root@luke-VirtualBox:/var/lib/mysql# cd /etc/mysql/
root@luke-VirtualBox:/etc/mysql# ll
总用量 32
drwxrwxrwx   4 mysql mysql  4096 12月 10 06:53 ./
drwxr-xr-x 123 root  root  12288 12月 10 06:54 ../
drwxr-xr-x   2 mysql mysql  4096 12月 10 06:53 conf.d/
lrwxrwxrwx   1 mysql mysql    24 12月  9 15:35 my.cnf -> /etc/alternatives/my.cnf
-rw-r--r--   1 mysql mysql   839 8月   3  2016 my.cnf.fallback
-rw-r--r--   1 mysql mysql  1200 6月   7  2021 mysql.cnf
drwxr-xr-x   2 mysql mysql  4096 12月 10 09:05 mysql.conf.d/
root@luke-VirtualBox:/etc/mysql# cd mysql.conf.d/
root@luke-VirtualBox:/etc/mysql/mysql.conf.d# ll
总用量 12
drwxr-xr-x 2 mysql mysql 4096 12月 10 09:05 ./
drwxrwxrwx 4 mysql mysql 4096 12月 10 06:53 ../
-rwxrwxrwx 1 mysql mysql 1676 12月 10 09:05 mysqld.cnf*
root@luke-VirtualBox:/etc/mysql/mysql.conf.d# more mysqld.cnf 
# Copyright (c) 2014, 2021, Oracle and/or its affiliates.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0,
# as published by the Free Software Foundation.
#
# This program is also distributed with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation.  The authors of MySQL hereby grant you an additional
# permission to link the program and your derivative works with the
# separately licensed software that they have included with MySQL.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

#
# The MySQL  Server configuration file.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

[mysqld]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
log-error       = /var/log/mysql/error.log
# By default we only accept connections from localhost
bind-address    = 0.0.0.0
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
#innodb_force_recovery = 6
#innodb_purge_threads = 1
#skip-name-resolve
#skip-grant-tables
root@luke-VirtualBox:/etc/mysql/mysql.conf.d# 

数据存储路径

datadir         = /var/lib/mysql

客户端登录 mysql 验证。
mysql  -uroot 

恢复后使用恢复文件中的用户名密码.

show databases; 查看库

use llll 进入库

show tables; 查看表

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
引用中的错误提示信息是由于在MySQL中插入了一个不兼容的字符,导致字符串值无法正确存储在数据库的'sName'列中。具体来说,'\xE7\x94\xB7'是一个十六进制值,代表着一个无法识别的字符。这个错误提示是说在插入的过程中,该字符无法正确地转换为有效的字符串值。 引用中的SQL语句是用来更新MySQL用户的身份验证字符串的。具体地说,它将用户'root'的身份验证字符串设置为'123qwe'。这条语句是一种常见的方式来更改MySQL用户的密码。 引用中的错误消息是在尝试启动MySQL服务时发生的。具体地说,它指出系统错误5,即拒绝访问。这意味着当前的用户权限不足以执行启动MySQL服务的操作。 综上所述,'\xE7\x94\xB7'是一个无法识别的字符,可能导致数据库插入错误。引用提供了一种更改MySQL用户密码的方式。而引用中的错误消息表示启动MySQL服务时遇到了权限问题,可能需要更高的权限来执行该操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [[问题处理]MySQL5.7问题集](https://blog.csdn.net/weixin_36005427/article/details/113675237)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值