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/*

清理数据后重新进行安装:
mysqld --initialize --datadir=/home/sdc/3306 (如果mysql版本小于5.7,可用mysql_install_db --datadir=/home/sdc/3306命令进行重装)
安装成功后,配置文件修改如下:

启动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无法启动,备份数据、重新安装。
mysql 5.7 停电导致无法启动、如何备份数据,重新安装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 ...
随机推荐
- Elasticsearch单机部署
1.下载安装包 下载地址:https://www.elastic.co/downloads/elasticsearch 我这里下载的是 elasticsearch-6.4.0.tar.gz保存至/op ...
- SpringBoot 配置Druid:不显示SQL监控 —(*) property for user to setup
题外话: SpringBoot整合Druid 请查看https://www.cnblogs.com/JealousGirl/p/druid.html Druid登录后数据源页面.SQL监控等不显示数据 ...
- ubuntu之路——day8.2 深度学习优化算法之指数加权平均与偏差修正,以及基于指数加权移动平均法的动量梯度下降法
首先感谢吴恩达老师的免费公开课,以下图片均来自于Andrew Ng的公开课 指数加权平均法 在统计学中被称为指数加权移动平均法,来看下面一个例子: 这是伦敦在一些天数中的气温分布图 Vt = βVt- ...
- Unity火爆插件Behavior Designer行为树插件学习
如果要让游戏里的角色或者NPC能执行预设的AI逻辑,最简单的用IF..ELSE...神器既可以实现, 但是再复杂的一般用经典的状态机来切换状态,但是写起来比较麻烦.相对的,行为树(Behavior T ...
- vmWare安装centos7之后使用yum安装提示there are on enabled repos(修改yum源)
可以使用这个命令修改yum源 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.rep ...
- api-ms-win-crt-runtime-l1-1-0.dll 丢失
api-ms-win-crt-runtime就是MFC的运行时环境的库,python在windows上编译也是用微软的visual studio C++编译的,底层也会用到微软提供的C++库和runt ...
- Kali Linux软件更新日报20190623
Kali Linux软件更新日报20190623 (1)payloadsallthethings更新到2.0-0kali4,此次更新增加帮助脚本. (2)tftpd32更新到4.50-0kali2 ...
- numpy linspace
https://www.cnblogs.com/antflow/p/7220798.html numpy.linspace(start, stop, num=50, endpoint=True, re ...
- c# 验证
public class RegularExpressionsHelper { /// <summary> /// 对用户名进行格式进行检查的正则表达式 /// </summary& ...
- jenkins结合httprunner配置实现自动化测试
jenkins结合httprunner配置实现自动化测试 自动化测试思路: jenkins发布代码到预发布环境 –> 触发自动化测试预发布环境 à 返回测试结:如果测试通过则将代码推送到生产环境 ...