9

Hopefully someone can help me, I've researched many of the recovery answers on stackoverflow.

I did the mistake of copying the data folder from mysql and pasting it in the new wamp 2.5 mysql/mysl5.6.17/data folder.

When I click on a table it gives "table doesn't exist". This below shows the what's showing

3688 [Warning] InnoDB: Cannot open table craigmedia/wp_eg_grids from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb troubleshooting.html for how you can resolve the problem.

I have my database folder that contains the .frm files.

I've been trying to use mysqlfrm to recover the table, as explained by this link: https://dba.stackexchange.com/questions/71596/restoring-mysql-tables-from-ibd-frm-and-mysqllogbin-files

However when I put the information into the mysqlfrm the results are show below:

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.

Execution of utility: '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' ended with return code '1' but no error message was streamed to the standard error, please review the output from its execution.

Then I tried this.

2. mysqlfrm --server=root@localhost:3306 c:/wamp/bin/mysql/mysql5.6.17/data/craigmedia/wp_eg_grids.frm --port=3307 --user=root

WARNING: Using a password on the command line interface can be insecure.

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'

At the moment I'm trying to access one .frm to test, which is the wp_eg_grids.frm and make it into a wp_eg_grids.txt. Can anyone notice what I'm doing wrong or know how to solve this please.

Community
  • 1
  • 1
Loncey Craig
  • 91
  • 1
  • 1
  • 3

2 Answers2

5

Try using the following syntax for mysqlfrm it had worked for me in a similar situation.

mysqlfrm --server=root:password@localhost:3306 c:/wamp/bin/mysql/mysql5.6.17/data/craigmedia/wp_eg_grids.frm > c:/wamp/bin/mysql/mysql5.6.17/data/craigmedia/wp_eg_grids.txt --diagnostic --port=3307 -vvv --user=root

Turn on diagnostic mode to read .frm files byte-by-byte and generate best-effort CREATE statement.

  • make sure to run as admin – tsukimi Nov 21 '17 at 06:56
  • 1
    This solution really helped me. I stayed up all night working on this, looking for answers. First, I had sha256 authentication issues using mysql utilities and had to work that out. Then I had the exact same problem with virtually the same traceback as Loncey. I got warnings that diagnostic mode was not error-proof, but my results were fine. Now I need to figure out how to get the data from the ibd files. – brohjoe Jul 25 '19 at 12:00
  • Thanks. This syntax seems working. However, I get: `UnicodeDecodeError: 'ascii' codec can't decode byte 0x92 in position 24: ordinal not in range(128)`. My database has collation `uf8_general_ci`. I assume that the MySQL Connector Python 2.1 for Python 2.7 tries to decode using Python's default string encoding (i.e. 'ascii') and so does mysqlfrm. Does someone know if mysqlfrm can also work with databases using utf8 collations and how to configure that? – OuzoPower Oct 30 '19 at 21:28
  • @OuzoPower i can't actually remember if the db that this was used was `utf8_general_ci`, but try checking this out https://bugs.mysql.com/bug.php?id=69631 i think it will help if the Python version is correct. There is a possibility to have used that fix also in my situation but i really don't remember for sure... –  Oct 30 '19 at 22:47
  • That solution didn't help me, always get error Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist even if it exist, but I'm on Ubuntu – Sebastian Dec 29 '19 at 19:24
  • @Sebastian in your occasion this might also be helpful https://stackoverflow.com/questions/9083408/fatal-error-cant-open-and-lock-privilege-tables-table-mysql-host-doesnt-ex –  Dec 29 '19 at 23:47
  • @user2560539 Unfortunately I don't understand how and where should I apply [this](https://bugs.mysql.com/bug.php?id=69631) fix. – JConstantine Jun 01 '21 at 07:52
0

Your issue may be similar to mine: MySQL spawned server doesn't start.

The issue lies in MySQL starting with a temporary datadir, which by default is the current directory. In this directory, you'll have a new temporary directory (something like 62a77962-9a4b-49d0-b91a-a5e9eb71b894), with correct permissions.

  • Linux: if you run as root (the user running mysqlfrm, not the user you start MySQL against), you most probably are in the /root/ directory, which mysql system user can't read (even if the mysql user is root).
  • Windows: same issue I think, if you run as administrator, the MySQL user may not have the rights to read the current directory.

The solution is to move (using cd) in a MySQL readable directory, such as /tmp/ on Linux (with all the security issues associated with this world readable directory), or perhaps C:\ on Windows.

I found it by looking at MySQL log (Linux: /var/log/mysql/mysql.log) which stated:

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

Start command was:

/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

Moving in /tmp/ fixed the issue, and mysqlfrm worked as expected.

I would have used a tmpdir option if available, but it isn't, as stated in 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)

And MySQL doesn't have a real home... or you may not want to mess with the /var/lib/mysql/ directory!

Yvan
  • 2,539
  • 26
  • 28