使用mysqlfrm恢复.frm文件时出现的问题

9
希望有人能帮助我,我已经在stackoverflow上研究了许多恢复答案。 我犯了一个错误,将mysql的数据文件夹复制并粘贴到新的wamp 2.5 mysql/mysl5.6.17/data文件夹中。 当我点击表时,它会显示“表不存在”。下面显示了具体信息: 3688 [警告] InnoDB:无法从InnoDB的内部数据字典中打开表craigmedia/wp_eg_grids,尽管该表的.frm文件存在。请参阅http://dev.mysql.com/doc/refman/5.6/en/innodb troubleshooting.html以了解如何解决此问题。 我有包含.frm文件的数据库文件夹。 我一直在尝试使用mysqlfrm来恢复表,就像这个链接所解释的那样:https://dba.stackexchange.com/questions/71596/restoring-mysql-tables-from-ibd-frm-and-mysqllogbin-files 然而,当我将信息输入到mysqlfrm中时,结果如下所示:
1.mysqlfrm --server=root@localhost --port=445 --user=root C:/wamp/bin/mysql/mysql5.6.17/data/craigmedia/wp_eg_grids.frm > wp_eg-grids.txt


Source on localhost: ...connected

ERROR: Cannot read wp_eg_grids.txt. You must have read privileges to the file or path and it must exist. Skipping this argument.
ERROR: Cannot read .frm file from >.frm.

执行实用程序:'mysqlfrm --server=root@localhost --port=445 --user=root C:/wamp/bin/mysql/mysql5.6.17/data/craigmedia/wp_eg_grids.frm > wp_eg-grids.txt' 以返回代码'1'结束,但没有错误消息流到标准错误输出,请检查其执行的输出。 然后我尝试了这个。
2. mysqlfrm --server=root@localhost:3306 c:/wamp/bin/mysql/mysql5.6.17/data/craigmedia/wp_eg_grids.frm --port=3307 --user=root

警告:在命令行界面上使用密码可能不安全。

Source on localhost: ...connected.
Spawning server with --user=root.
Starting the spawned server on port 3307 ...

The console has detected that the utility 'mysqlfrm' ended with an error code. You can get more information about the error by running the console command 'show last error'.

Execution of utility: 'mysqlfrm --server=root@localhost:3306 c:/wamp/bin/mysql/mysql5.6.17/data/craigmedia/wp_eg_grids.frm --port=3307 --user=root' ended with return code '1' and with the following error message:
Traceback <most recent call last>:

File "G:\ade\build\sb_0-16088143-1438774726.78\Python-2.7.6-windows-x86-64bit\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
File "scripts\mysqlfrm.py", line 422, in <module>
File ".\mysql\utilities\command\read_frm.py", line 439, in read_frm_files
File ".\mysql\utilities\command\read_frm.py", line 166, in _spawn_server
File ".\mysql\utilities\command\serverclone.py", line 180, in clone_server
File ".\mysql\utilities\command\tools.py", line 254, in get_mysqld_version

I0Error: [Errno 13] Permission denied: 'version_check'

目前我正在尝试访问一个.frm文件进行测试,该文件是wp_eg_grids.frm,并将其转换为wp_eg_grids.txt。是否有人能注意到我做错了什么或者知道如何解决这个问题,请告诉我。


1
最近一直遇到同样的问题。有解决的办法吗? - pfinferno
嘿,不好意思,我没有成功,最终我重新做了我的网站。 - Loncey Craig
请确保以管理员身份运行控制台。 - tsukimi
2个回答

5

请以管理员身份运行。 - tsukimi
1
这个解决方案真的帮了我很大忙。我熬了一整晚,寻找答案。首先,我在使用mysql工具时遇到了sha256认证问题,不得不解决它。然后我又遇到了和Loncey几乎相同的问题,出现了完全相同的回溯信息。我收到了警告,说诊断模式并不是错误免疫的,但我的结果还是很好的。现在我需要弄清楚如何从ibd文件中获取数据。 - brohjoe
@OuzoPower 我实际上无法记得这个程序所使用的数据库是否为 utf8_general_ci,但是请尝试查看此链接 https://bugs.mysql.com/bug.php?id=69631 ,如果 Python 版本正确,则应该会有帮助。在我的情况下也可能已经使用了那个修复方法,但我真的不确定... - user2560539
那个解决方案对我没有帮助,我总是得到错误信息“无法打开和锁定特权表:表'mysql.servers'不存在”,即使它存在,但我使用的是Ubuntu系统。 - Sebastian
很抱歉,我不明白应该在哪里以及如何应用 这个 修复程序。 - JConstantine
显示剩余2条评论

0

你的问题可能与我的类似:MySQL生成的服务器无法启动。

问题在于MySQL使用临时datadir启动,默认情况下是当前目录。在此目录中,您将拥有一个新的临时目录(类似于62a77962-9a4b-49d0-b91a-a5e9eb71b894),具有正确的权限。

  • Linux:如果您以root身份运行(运行mysqlfrm的用户,而不是您针对MySQL启动的用户),则您很可能位于/root/目录中,该目录mysql系统用户无法读取(即使mysql用户是root)。
  • Windows:我认为是相同的问题,如果您以管理员身份运行,则MySQL用户可能没有读取当前目录的权限。

解决方案是移动(使用cd)到MySQL可读目录,例如Linux上的/tmp/(带有与此world readable目录相关的所有安全问题),或者在Windows上使用C:\

我通过查看MySQL日志(Linux:/var/log/mysql/mysql.log)找到了它,其中写道:

/usr/sbin/mysqld: Can't change dir to '/root/aa9fe487-0c77-4bb4-a829-036fc9919558/' (Errcode: 13 - Permission denied)

启动命令是:

/usr/sbin/mysqld --no-defaults --basedir=/usr --datadir=/root/aa9fe487-0c77-4bb4-a829-036fc9919558 --pid-file=/root/aa9fe487-0c77-4bb4-a829-036fc9919558/clone.pid --port=3310 --server-id=101 --socket=/root/aa9fe487-0c77-4bb4-a829-036fc9919558/mysql.sock --tmpdir=/root/aa9fe487-0c77-4bb4-a829-036fc9919558 --user=mysql

将目录更改为/tmp/解决了问题,并且mysqlfrm按预期工作。

如果有的话,我会使用tmpdir选项,但是如read_frm.py所述,它并不存在:

# Since Python libraries correctly restrict temporary folders to
# the user who runs the script and /tmp is protected on some
# platforms, we must create the folder in the current folder
   temp_datadir = os.path.join(os.getcwd(), str(uuid.uuid4()))
   os.mkdir(temp_datadir)

而MySQL并没有一个真正的主目录... 或者你可能不想去捣乱 /var/lib/mysql/ 目录!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接