mysql无法启动如何备份文件_mysql 5.7 停电导致无法启动、如何备份数据,重新安装mysql...
用于記錄服務(wù)器停電導(dǎo)致,mysql啟動失敗后,如何備份數(shù)據(jù),重新安裝mysql,主要分為數(shù)據(jù)備份,mysql重新安裝。
1、mysql無法啟動時(shí),進(jìn)行數(shù)據(jù)備份。
執(zhí)行:systemctl start mysqld,啟動失敗。
錯(cuò)誤提示:Job for mysqld.service failed because start of the service was attempted too often. See "systemctl status mysqld.service" and "journalctl -xe" for details.
執(zhí)行命令:journalctl -xe,發(fā)現(xiàn)由于文件損壞導(dǎo)致,myslq無法正常啟動。
錯(cuò)誤提示:
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啟動時(shí)忽略檢查到錯(cuò)誤文件,在配置文件/etc/my.cnf中添加配置項(xiàng)innodb_force_recovery:
vim /etc/my.cnf
innodb_force_recovery=1
添加配置后啟動mysql:systemctl start mysqld
執(zhí)行一下命令,對數(shù)據(jù)進(jìn)行備份:
mysqldump -uroot -proot --all-databases? > all_mysql_backup.sql
到此數(shù)據(jù)備份已完成,接下來會mysql進(jìn)行重新安裝。
2、重新安裝mysql 5.7
先清除原有的mysql數(shù)據(jù)。如mysql安裝路徑為:/home/sdc/3306
rm -rf /home/sdc/3306/*
清理數(shù)據(jù)后重新進(jìn)行安裝:
mysqld --initialize?--datadir=/home/sdc/3306?(如果mysql版本小于5.7,可用mysql_install_db --datadir=/home/sdc/3306命令進(jìn)行重裝)
安裝成功后,配置文件修改如下:
啟動mysql:systemctl start mysqld
啟動之后,設(shè)置軟連接,不設(shè)置軟連接,會導(dǎo)致本地?zé)o法登錄。出現(xiàn)can't find mysql.sock錯(cuò)誤
ln -s /home/sdc/3306/mysql.sock /usr/lib/mysql/
對安裝路徑進(jìn)行授權(quán):chown -R mysql:mysql /home/sdc/3306/
獲取重裝后的初始化密碼:grep 'temporary password' /var/log/mysqld.log
登錄新安裝的mysql,設(shè)置新密碼:
mysql -uroot -p
>set password=password('root');
授權(quán)遠(yuǎn)程登錄:
>grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
>flush privileges;
>quit;
重新啟動mysql,使用source命令導(dǎo)入之前備份的數(shù)據(jù)。
#mysql -u root -p root -h ip -P 3306
>source /root/all_mysql_backup.sql;
>quit;
用于記錄停電導(dǎo)致mysql無法啟動,備份數(shù)據(jù)、重新安裝。
總結(jié)
以上是生活随笔為你收集整理的mysql无法启动如何备份文件_mysql 5.7 停电导致无法启动、如何备份数据,重新安装mysql...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python动态表情包下载_Python
- 下一篇: python深度优先_python数据结