mysql无法启动如何备份文件_mysql 5.7 停电导致无法启动、如何备份数据,重新安装mysql...

用于记录服务器停电导致,mysql启动失败后,如何备份数据,重新安装mysql,主要分为数据备份,mysql重新安装。

1、mysql无法启动时,进行数据备份。

执行:systemctl start mysqld,启动失败。

错误提示:Job for mysqld.service failed because start of the service was attempted too often. See "systemctl status mysqld.service" and "journalctl -xe" for details.

执行命令:journalctl -xe,发现由于文件损坏导致,myslq无法正常启动。

错误提示:

InnoDB: End of page dump

2019-07-08T10:32:02.562744Z 0 [Note] InnoDB: Uncompressed page, stored checksum in field1 1648005559, calculated checksums for field1: crc32 1648005559/4122850020, innodb 1498368068, none 3735928559, stored checksum in field2 878221460, calculated checksums for field2: crc32 1648005559/4122850020, innodb 2300197431, none 3735928559, page LSN 0 1480595787, low 4 bytes of LSN at page end 1480663732, page number (if stored to page already) 318, space id (if created with >= MySQL-4.1.1 and stored already) 0

InnoDB: Page may be an update undo log page

2019-07-08T10:32:02.562804Z 0 [Note] InnoDB: It is also possible that your operating system has corrupted its own file cache and rebooting your computer removes the error. If the corrupt page is an index page. You can also try to fix the corruption by dumping, dropping, and reimporting the corrupt table. You can use CHECK TABLE to scan your table for corruption. Please refer to http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html for information about forcing recovery.

2019-07-08T10:32:02.562824Z 0 [ERROR] [FATAL] InnoDB: Aborting because of a corrupt database page in the system tablespace. Or, there was a failure in tagging the tablespace as corrupt.

2019-07-08 18:32:02 0x7f22aee65780 InnoDB: Assertion failure in thread 139786939946880 in file ut0ut.cc line 942

编辑mysql配置文件,使mysql启动时忽略检查到错误文件,在配置文件/etc/my.cnf中添加配置项innodb_force_recovery:

vim /etc/my.cnf

innodb_force_recovery=1

添加配置后启动mysql:systemctl start mysqld

执行一下命令,对数据进行备份:

mysqldump -uroot -proot --all-databases  > all_mysql_backup.sql

到此数据备份已完成,接下来会mysql进行重新安装。

2、重新安装mysql 5.7

先清除原有的mysql数据。如mysql安装路径为:/home/sdc/3306

rm -rf /home/sdc/3306/*

db21e24d0f6429fb303e61ad5115de00.png

清理数据后重新进行安装:

mysqld --initialize --datadir=/home/sdc/3306 (如果mysql版本小于5.7,可用mysql_install_db --datadir=/home/sdc/3306命令进行重装)

安装成功后,配置文件修改如下:

8ae83e630de3fcbca65d73c0b035d166.png

启动mysql:systemctl start mysqld

启动之后,设置软连接,不设置软连接,会导致本地无法登录。出现can't find mysql.sock错误

ln -s /home/sdc/3306/mysql.sock /usr/lib/mysql/

对安装路径进行授权:chown -R mysql:mysql /home/sdc/3306/

获取重装后的初始化密码:grep 'temporary password' /var/log/mysqld.log

登录新安装的mysql,设置新密码:

mysql -uroot -p

>set password=password('root');

授权远程登录:

>grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;

>flush privileges;

>quit;

重新启动mysql,使用source命令导入之前备份的数据。

#mysql -u root -p root -h ip -P 3306

>source /root/all_mysql_backup.sql;

>quit;

用于记录停电导致mysql无法启动,备份数据、重新安装。

innobackupex 备份数据搭建 MySQL Slave

简介: 数据量比较大时,使用 innobackupex 备份数据新增 MySQL Slave 节点. 安装 innobackupex 工具,我这里写过一次:http://www.cnblogs.com ...

mysql innodb数据库损坏导致无法启动

生产环境中的mysql突然启动不了,查了原因是innodb库错误,以前就遇到过这个问题,稀里糊涂的没解决,结果导致大量数据丢失.这些又遇到这个问题,果断把那个有问题的数据库移动了别的地方,启动了mys ...

一次Mysql连接池卡死导致服务无响应问题分析(.Net Mysql.Data 6.9.9)

问题: 进程启动后,线程数迅速上升至最小线程数后,缓慢上升(线程池限制)到数千,然后由于线程过多,CPU飙升到90%. 对外表现为Api无响应或连接超时. 背景 有些数据存在于另一个机房,通过内网专线 ...

手动进行Excel数据和MySql数据转换

今天是全国数学建模比赛,同学选的一个题目需要对一个large的Excel表格进行统计,好哥们儿嘛--便帮助他完成了数据从Excel到MySql的转化.记下具体步骤分享给大家,也免得大家到网上到处乱找了 ...

将Excel数据导入mysql数据库的几种方法

将Excel数据导入mysql数据库的几种方法 “我的面试感悟”有奖征文大赛结果揭晓! 前几天需要将Excel表格中的数据导入到mysql数据库中,在网上查了半天,研究了半天,总结出以下几种方法,下面 ...

将Excel数据导入MySql

1.将选中的数据快儿拷贝到一个TXT文本文件中(记得把后面的空格消掉..),假如存到“D:\data.txt”这个位置里. 2.根据要导入的数据快儿建立MySql数据库和表,然后进入命令提示符里使用命 ...

Excel连接到MySQL,将Excel数据导入MySql,MySQL for Excel,,

Excel连接到MySQL 即使当今时代我们拥有了类似微软水晶报表之类的强大报表工具和其他一些灵活的客户管 理应用工具,众多企业在分析诸如销售统计和收入信息的时候,微软的Excel依然是最常用的工具. ...

解决MySQL因不能创建 PID 导致无法启动的方法

问题描述 MySQL 启动报错信息如下: ? 1 2 Starting mysqld (via systemctl):  Job for mysqld.service failed because t ...

Docker中mysql修改配置导致无法启动的docker容器

宿主机中查找my.cnf文件 # find / -name my.cnf |grep '/etc/mysql/my.cnf' 找到: /data/docker/overlay2/dfc2ddbed53 ...

随机推荐

const char* && string && String^ 类型转换

const char* && string && String^ 类型转换 const char* ---> string const char * cw= &q ...

strcmp函数实现及分析

最近看C,看到strcmp函数,对它的实现原型不很清楚,于是到网上搜.网上算法一大堆,看了很多代码后自己做了一下总结 strcmp函数是C/C++中基本的函数,它对两个字符串进行比较,然后返回比较结果 ...

Nim Game 解答

Question You are playing the following Nim Game with your friend: There is a heap of stones on the t ...

eclipse默认编码设置为utf-8

需要设置的几处地方为: Window->Preferences->General ->Content Type->Text->JSP 最下面设置为UTF-8 Window ...

hdu-2814-Interesting Fibonacci-斐波那契周期节

哇,其实我2A该....否1A纯脑损伤.. 乞讨:F(a^b)^(F(a^b) ^ (n-1))%c  既是求F(a^b)^(F(a^b) ^ (n-1)%phi[c]+phi[c])%c 先求x=F ...

Django细节小记

前记:Django的ORM.模块有很多函数细节,要学会多看文档学习函数的细节 聚合annotate()和aggregate()的使用 简言之,annotate()得到的是查询集,类似all(),只不过 ...

windows平台mysql密码设置

登录mysql默认没有指定账号 查看默认账号是谁 select user(); mysql> select user();+----------------+| user() |+------- ...

构建第一个Spring Boot项目

1.启动IntelliJ IDEA,点击"Create New Project"  2.选择"Spring initializr",设定SDK及Spring ...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值