HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

MySQL restore lost data after update from 5.7 -> 8.0.11

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
afterlostupdatemysqlfromdatarestore

Problem

I have a docker-compose file where I use the official mysql:latest image as my database server.

After a docker pull mysql and a docker-compose up the image updated from 5.7 -> 8.0.11

This update corrupted all my mysql data.

All .frm files got deleted.

When I try to restart the mysql-server I get the following error, even with innodb_force_recovery [1-6]

```
2018-06-05T19:19:14.624533Z 0 [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file ./ibdata1 are 0x4000!
2018-06-05 19:19:14 0x7fd24a8b6740 InnoDB: Assertion failure in thread 140541170509632 in file ut0ut.cc line 942
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
19:19:14 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
Attempting to collect some information that could help diagnose the problem.
As this is a crash and something is definitely wrong, the information
collection process might fail.

key_buffer_size=8388608
read_buffer_size=131072
-> Executing /opt/docker/provision/entrypoint.d/05-permissions.sh
max_used_connections=0
-> Executing /opt/docker/provision/entrypoint.d/20-nginx.sh
max_threads=151
-> Executing /opt/docker/provision/entrypoint.d/20-php-fpm.sh
thread_count=0
connection_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68195 K bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointe

Solution

I was finally successful restoring the data. My problem was, that I tried to restore the data with a docker-compose, which somehow didn't work.

So I took a different approach

  1. Run a docker image of mysql:8 and mounted the "corrupt" folder to it



docker run -d -e MYSQL_ROOT_PASSWORD=root -v /path/to/corrupt/folder:/var/lib/mysql --name mrestore mysql:8


The mysql-server started without any problems and I was able to run mysql with

mysql -u root -p.

But when I run the command mysql>show databases; It gave me an error like:

The user specified as a definer ('mysql.infoschema'@'localhost') does not exist


  1. Fix user does not exist error



A quick google search led me to the answer of someone having the same problem: https://stackoverflow.com/questions/49992868/mysql-errorthe-user-specified-as-a-definer-mysql-infoschemalocalhost-doe

Which is:

mysql -u root -p
mysql> SET GLOBAL innodb_fast_shutdown = 1;
mysql_upgrade -u root -p


  1. Dump databse



Finally I was able to start mysql and dump the database that I thought I've lost

mysqldump -u root -p databasename > databasename.sql

Code Snippets

docker run -d -e MYSQL_ROOT_PASSWORD=root -v /path/to/corrupt/folder:/var/lib/mysql --name mrestore mysql:8
The user specified as a definer ('mysql.infoschema'@'localhost') does not exist
mysql -u root -p
mysql> SET GLOBAL innodb_fast_shutdown = 1;
mysql_upgrade -u root -p
mysqldump -u root -p databasename > databasename.sql

Context

StackExchange Database Administrators Q#209295, answer score: 4

Revisions (0)

No revisions yet.