This error message shows up when I use ubuntu 16.04 and the latest mysql 5.7.19-0ubuntu0.16.04.1 in a Docker image.
What could be done to fix this?
To reproduce the error
Get the
Dockerfile
:FROM ubuntu:16.04 RUN apt update RUN DEBIAN_FRONTEND=noninteractive apt install -y mysql-server
(also available here)
Build and run:
docker build -t mysqlfail . docker run -it mysqlfail tail -1 /var/log/mysql/error.log
would have been shown the following error log:
2017-08-26T11:48:45.398445Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
Which was exactly what we wanted: a mysql with no root password set yet.
In the past (ubuntu 14.04 / mysql 5.5) a
service mysql start
was possible. Now if you try this it failsdocker run -it mysqlfail service mysql start * Starting MySQL database server mysqld No directory, logging in with HOME=/ [fail]
and
/var/log/mysql/error.log
contains a line:2017-08-26T11:59:57.680618Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table storage engine for 'user' doesn't have this option
build log (for the complete Dockerfile
)
Sending build context to Docker daemon 2.56kB
Step 1/4 : FROM ubuntu:16.04
---> ebcd9d4fca80
...
Step 4/4 : RUN service mysql start
---> Running in 5b899739d90d
* Starting MySQL database server mysqld
...fail!
The command '/bin/sh -c service mysql start' returned a non-zero code: 1
weird continuation
After experiments as outlined in my answer attempt, I created a shell script that does a
select count(*)
query on each table in the mysql space three times in a row (because experiments show that on some tables the query will fail exactly twice :-( ).
Then a
mysql_upgrade
and the
service mysql restart
is tried. In the Dockerfile
the script is made available via
COPY mysqltest.sh .
The trials with this script give weird/crazy results.
For the
Docker environment
the start still fails[ERROR] Fatal error: Can't open and lock privilege tables: Table storage engine for 'user' doesn't have this option
Running the script
sh mysqltest.sh root
in the
docker environment
leads to2017-08-27T09:12:47.021528Z 12 [ERROR] /usr/sbin/mysqld: Table './mysql/db' is marked as crashed and should be repaired
2017-08-27T09:12:47.050141Z 12 [ERROR] Couldn't repair table: mysql.db
2017-08-27T09:12:47.055925Z 13 [ERROR] /usr/sbin/mysqld: Table './mysql/db' is marked as crashed and should be repaired
2017-08-27T09:12:47.407700Z 54 [ERROR] /usr/sbin/mysqld: Table './mysql/proc' is marked as crashed and should be repaired
2017-08-27T09:12:47.433516Z 54 [ERROR] Couldn't repair table: mysql.proc
2017-08-27T09:12:47.440695Z 55 [ERROR] /usr/sbin/mysqld: Table './mysql/proc' is marked as crashed and should be repaired
2017-08-27T09:12:47.769485Z 81 [ERROR] /usr/sbin/mysqld: Table './mysql/tables_priv' is marked as crashed and should be repaired
2017-08-27T09:12:47.792061Z 81 [ERROR] Couldn't repair table: mysql.tables_priv
2017-08-27T09:12:47.798472Z 82 [ERROR] /usr/sbin/mysqld: Table './mysql/tables_priv' is marked as crashed and should be repaired
2017-08-27T09:12:47.893741Z 99 [ERROR] /usr/sbin/mysqld: Table './mysql/user' is marked as crashed and should be repaired
2017-08-27T09:12:47.914288Z 99 [ERROR] Couldn't repair table: mysql.user
2017-08-27T09:12:47.920459Z 100 [ERROR] /usr/sbin/mysqld: Table './mysql/user' is marked as crashed and should be repaired
What is going on here to cause this strange behavior?