mysql直接複製檔案遷移問題

2021-10-05 12:30:17 字數 1511 閱讀 8468

由於各種原因,重啟伺服器導致mysql再也啟動不了

service mysql start

報錯job for mysql.service failed because the control process exited with error code. see "systemctl status mysql.service" and "journalctl -xe" for details.然後把裡面的乙個表的資料夾+ibdata1(innodb才需要拷貝這個)拷貝進去,刪掉ib_logfile1和ib_logfile0兩個檔案,執行

service mysql start

報錯不變,檢視日誌:

can't create test file /var/lib/mysql/****

判斷是因為許可權問題導致對原檔案不能進行操作。

給ibdata1直接上777許可權。然後刪掉ib_logfile1和ib_logfile0兩個檔案。

可以啟動mysql,馬上現場連線mysql,輸入賬號密碼,可以登入進去。切換到複製進去的資料庫,可以切換,對錶進行查詢。報錯:

error 2006 (hy000): mysql server has gone away no connection. trying to reconnect... connection id: 3 current database: tmss

var/lib/log/mysql 中檢視日誌有error:

[error] innodb: operating system error number 2 in a file operation. [error] innodb: the error means the system cannot find the path specified. [error] innodb: if you are installing innodb, remember that you must create directories yourself, innodb does not create them. [error] innodb: cannot open datafile for read-only: './ ******x/******x.ibd' os error: 71 [error] innodb: operating system error number 2 in a file operation.

看到了 cannot open datafile 說明是無法開啟檔案。可以看出又是許可權問題了。

選中拷貝進去的資料庫資料夾設定許可權 777

進入資料夾選中所有檔案 設定許可權777

刪掉ib_logfile1和ib_logfile0

service mysql restart

重啟好後進入登入資料庫,切換資料庫,對錶進行查詢。出資料了。解決了。

趕緊匯出sql檔案,然後重新建庫匯入sql。

最後:就都是檔案的許可權問題。

MySQL資料庫遷移(直接複製檔案)

mysql 資料庫遷移 資料檔案直接遷移 在今年10月下旬的時候,公司的伺服器需要遷移,其中涉及到了mysql資料庫遷移。檢視了一下mysql資料檔案的大小,接近60g的大小 實際資料並沒用那麼多 由於伺服器上業務需要,要儘量減少伺服器遷移時的損失。所以遷移時間選在了晚上零點開始,而且要儘量減少遷移...

Mysql資料庫遷移 資料檔案直接遷移

mysql資料庫遷移 資料檔案直接遷移 在遷移之前有三種方案 1 資料庫直接匯出,拷貝檔案到新伺服器,在新伺服器上匯入。2 使用 mysql gui tools 中的 mysqlmigrationtool。3 資料檔案和庫表結構檔案直接拷貝到新伺服器,掛載到同樣配置的mysql服務下。我在我的電腦上...

Mysql資料庫遷移(資料檔案直接遷移)

最近在進行打包專案開發的時候,最初打包後的資料是版本一。經過測試階段測試後,以及修改 等等。在最後終於需求bug該改的都改了。準備自行再在windows虛擬機器上進行測試打包後的專案,那麼則要更新打包後的版本一資料,變成最新版本資料。我的專案是web專案 mysql資料庫遷移 資料檔案直接遷移 如下...