問題描述
我在 Centos 6 服務器中從 Mysql 5.5 更新到 8.0,沒有將數據庫轉儲到 .sql 文件,我只是將/var/lib/mysql 目錄復制到另一個位置.
I did an update from Mysql 5.5 to 8.0 in a Centos 6 server without dumping the databases to a .sql file, I just copied the /var/lib/mysql directory to another location.
現在,如果我嘗試加載 mysqld 服務,它會崩潰.
Now if I try to load mysqld service it crashes.
天真我刪除了/var/lib/mysql的所有內容并重新安裝了該服務,現在它可以運行但現在我不知道如何手動將數據庫文件導入目錄(復制并粘貼文件夾不起作用)以檢查數據庫和/或修復它.
Being naive I deleted all the content of /var/lib/mysql and installed the service again, now it runs but now I do not know how to manually import the DB files to the directory (copy & paste of the folder does not work) in order to do a check of the DB and/or repair it.
推薦答案
rysnc 應該可能已經安裝,但如果沒有,你會:
rysnc should likely already be installed, but if it isn't you would:
sudo yum install rsync
然后
#make sure mysql isn't running
sudo service mysqld stop
#double check that there is no MySQL PID running
sudo ps aux | grep mysql
#move the new MySQL 8.0 data files out of the way
sudo mv /var/lib/mysql /var/lib/mysql.bak
#copy the original data files back to /var/lib/mysql
#note that the trailing / is required for both paths
sudo rsync -av /path/to/original/mysql/db/files/ /var/lib/mysql/
#change user and group ownership to mysql
sudo chown -R mysql:mysql /var/lib/mysql
#start MySQL
sudo service mysqld start
#run mysql_upgrade, replace {usernamehere} with the actual username
sudo mysql_upgrade -u {usernamehere} -p
更新:
您需要將二進制文件降級到 5.5.一旦 MySQL 再次運行,請備份每個數據庫,然后按以下順序升級:
You will need to downgrade the binaries to 5.5. Take a backup of each database once MySQL is running again and then upgrade in the following order:
- 5.6
- 5.7
- 8.0
您需要在每次升級后運行 mysql_upgrade
.
You will need to run mysql_upgrade
after each upgrade.
這篇關于更新后恢復 MySQL/var/lib/mysql的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!