T
T
tegrato2020-02-26 09:22:45
MySQL
tegrato, 2020-02-26 09:22:45

How to restore MySQL DB from file /var/lib/mysql/ibdata1 ??

1. 2 MySQL databases have been removed. How can they be restored from the /var/lib/mysql/ibdata1 file ?
The server (Debian 9) was a test server, so no backups were made.
Restoring these databases is not "a matter of life and death", but the very possibility of restoration is very interesting, and the test server is just right for such experiments.
There is information on the net how to transfer a database from one server to another using the /var/lib/mysql/ibdata1 file , but all these cheat sheets are not applicable in my case.

2. There are LOG files: /var/lib/mysql/ib_logfile0 and /var/lib/mysql/ib_logfile1 , but an attempt to convert them with the command mysqlbinlog ib_logfile0 > 1.txtin a readable form gives an error:

mysqlbinlog: unknown variable 'default-character-set=utf8mb4'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
tegrato, 2020-02-26
@tegrato

Long googling and pestering various experts gave the following results:
1. Without the presence of at least an old database dump, it is impossible to restore.
2. You can view the contents of the /var/lib/mysql/ib_logfile0 , /var/lib/mysql/ib_logfile1 and /var/lib/mysql/ibdata1 files , in principle, without additional transformations, for example, using Notepad++ (but this is creepy not convenient, Notepad++ will slow down wildly with a file size of 40M+).
Therefore, it is desirable to first convert them into a more or less readable form using the command:


strings /var/lib/mysql/ib_logfile0 > /var/lib/mysql/ib_logfile0.txt

Then download the resulting text files, their size will be 3-4 times smaller.
If you do not know what was in the database, then it will not be easy to sort out this array of strings. But, in general, some of the information can be easily recognized.

V
Vladimir Korotenko, 2020-02-26
@firedragon

blog.vadimdenisov.ru/post/223


mysqlbinlog --no-defaults /var/lib/mysql/mysql-bin.000065 | tail -n 9
mysqlbinlog: O_TMPFILE is not supported on /tmp (disabling future attempts)
ERROR: Error in Log_event::read_log_event(): 'Event truncated', data_len: 1044004, event_type: 2
#191110 13:18:33 server id 1 end_log_pos 316384751 CRC32 0xb3498009 GTID 0-1-72255
/*!100001 SET @@session.gtid_seq_no=72255*//*!*/;
BEGIN
/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET [email protected]_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question