日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

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

發布時間:2024/9/27 数据库 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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/*

清理數據后重新進行安裝:

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无法启动如何备份文件_mysql 5.7 停电导致无法启动、如何备份数据,重新安装mysql...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。