在新的 MySQL 安装中使用以前的 MySQL 数据文件夹 [英] Using previous MySQL data folder on new MySQL installation
问题描述
如果我可以进行适当的 SQL 转储/备份
,我会这样做,但是 OS
失败了,只能登录到 SafeMode
,我无法启动 MySQL 服务器
.因此,我只能手动备份文件目录.
If I could have made a proper SQL dump/backup
I would have, but OS
gave out and could only log into SafeMode
, where I couldn't start the MySQL server
. Therefore, I could only manually backup the file directories.
- 我有 C:\ProgramData\MySQL\MySQL Server 8.0 的保存文件副本
- 我有 C:\Program Files\MySQL\MySQL Server 8.0 的保存文件副本
我现在正在新安装的 Windows
上运行并尝试启动这个旧服务器几分钟,以便我可以从 Workbench
登录并创建一个正确的 SQL 数据库转储
,稍后我将在新的 MySQL
安装中import
.
I'm now running on a new installation of Windows
and trying to start this old server up for a few minutes so I can log on from Workbench
and make a proper SQL database dump
which will I import
on a new MySQL
installation later.
因此,将提到的文件移动到各自的位置 - Program Files
和 ProgramData
.
Consequently, moving the mentioned files in their respective locations - Program Files
and ProgramData
.
打开PowerShell
(具有管理员权限)并执行:
Opening up PowerShell
(with Admin rights) and doing:
mysqld --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0" --console
我在屏幕上看到几行数百行,其中包含以下内容:
and I get a few hundred lines on the screen that contain the following:
2020-04-10T05:28:56.725818Z 0 [ERROR] [MY-011972] [InnoDB] Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html for information about forcing recovery.
2020-04-10T05:28:56.734460Z 0 [ERROR] [MY-011971] [InnoDB] Tablespace 'innodb_undo_001' Page [page id: space=4294967279, page number=5] log sequence number 1339677380 is in the future! Current system log sequence number 19081380.
关注:
2020-04-10T05:28:56.740834Z 0 [ERROR] [MY-011972] [InnoDB] Your database may be corrupt or you may have copied the InnoDB tablespace but not the InnoDB log files. Please refer to http://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html for information about forcing recovery.
2020-04-10T05:28:56.757259Z 0 [System] [MY-010229] [Server] Starting crash recovery...
2020-04-10T05:28:56.769215Z 0 [System] [MY-010232] [Server] Crash recovery finished.
2020-04-10T05:28:57.695386Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-04-10T05:28:57.765911Z 0 [System] [MY-010931] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: ready for connections. Version: '8.0.13' socket: '' port: 3306 MySQL Community Server - GPL.
2020-04-10T05:28:57.926850Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060
很棒,至少它正在运行.
Great, at least its running.
我现在可以连接
但没有数据库
.
- 我能做什么/我应该如何继续成功地暂时恢复这些数据库?
更新:
从数据目录中删除了 innodb_undo_001 和 innodb_undo_002 文件并重新启动.
Removed the innodb_undo_001 and innodb_undo_002 files from the Data directory and relaunched.
得到这个:
PS C:\Program Files\MySQL\MySQL Server 8.0\bin> .\mysqld --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --console 2020-04-10T05:55:29.555478Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2020-04-10T05:55:29.558313Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.13) starting as process 3028
2020-04-10T05:55:31.394427Z 1 [Warning] [MY-012351] [InnoDB] Tablespace 1, name 'sys/sys_config', file '.\sys\sys_config.ibd' is missing!
2020-04-10T05:55:32.808645Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-04-10T05:55:32.856154Z 0 [System] [MY-010931] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: ready for connections. Version: '8.0.13' socket: '' port: 3306 MySQL Community Server - GPL.
2020-04-10T05:55:32.898055Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060
正在运行但没有数据库.
尝试了 Innodb-force-recovery 方法 - 没有任何反应.和以前一样.
Tried the Innodb-force-recovery approach - nothing happens. Same as before.
推荐答案
好的,假设所有文件没有损坏,您可以尝试以下操作:
Ok, assuming that all the files are not corrupted, you can try the following:
- 创建一个新文件夹(如果可能,在不同的驱动器中).将其命名为
test
或其他名称.然后将C:\Program Files\MySQL\MySQL Server 8.0
目录中的所有文件复制到新文件夹中.
- Create a new folder (in a different drive if possible). Name it as
test
or something. Then copy all files from theC:\Program Files\MySQL\MySQL Server 8.0
directory into the new folder.
*注意:如果文件夹中没有 my.ini 文件,请将其从 C:\ProgramData\MySQL\MySQL Server 8.0
目录复制到文件夹中.
*note: if you don't have my.ini file in the folder, copy it from the C:\ProgramData\MySQL\MySQL Server 8.0
directory into the folder.
打开 my.ini 文件并更改以下内容:
Open my.ini file and change the following:
回到 my.ini 文件的顶部并更改:更改上述内容后,将 mysqld --install MySQLXY ..
的整行复制到最后.不要复制开头的第一个 #
.然后保存 my.ini 文件.
Go back to the top of my.ini file and change:
after changing above, copy the whole line from mysqld --install MySQLXY ..
to the end. Don't copy the first #
at the beginning. Then save the my.ini file.
以管理员身份打开命令提示符 (cmd),然后执行以下操作:
Open command prompt (cmd) as administrator then do this:
*使用cmd手动安装服务.
*installing the service manually using cmd.
进入服务(键盘快捷键windows button+R然后输入
services.msc
然后回车或者OK),找到新安装的MySQL服务点击start
.
Go to services (keyboard shortcut windows button+R then type
services.msc
then press ENTER or OK), find the newly installed MySQL service and clickstart
.
尝试连接到数据库.
这篇关于在新的 MySQL 安装中使用以前的 MySQL 数据文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!