Latest MySQL not coming up in Kubernetes

4/20/2018

I am seeing the following error in the container when deployed to the kubernetes. I have the line

spec:
  containers:
  - name: mysql
    image: mysql/mysql-server:latest
    args:
      - "--ignore-db-dir=lost+found"

in the config, do I need to include anything else

[Entrypoint] MySQL Docker Image 8.0.11-1.1.5
[Entrypoint] Starting MySQL 8.0.11-1.1.5
2018-04-20T15:20:54.975756Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.11) starting as process 1
mysqld: Table 'mysql.plugin' doesn't exist
2018-04-20T15:20:55.415098Z 0 [ERROR] [MY-010735] [Server] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2018-04-20T15:20:55.495353Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-04-20T15:20:55.499087Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2018-04-20T15:20:55.505667Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
2018-04-20T15:20:55.505905Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-001146 - Table 'mysql.component' doesn't exist
2018-04-20T15:20:55.505932Z 0 [Warning] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-003543 - The mysql.component table is missing or has an incorrect definition.
2018-04-20T15:20:55.506040Z 0 [ERROR] [MY-011071] [Server] unknown variable 'ignore-db-dir=lost+found'
2018-04-20T15:20:55.506057Z 0 [Warning] [MY-010952] [Server] The privilege system failed to initialize correctly. If you have upgraded your server, make sure you're executing mysql_upgrade to correct the issue.
2018-04-20T15:20:55.506137Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-04-20T15:20:57.198050Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.11)  MySQL Community Server - GPL.nterval of mirrorId has elapsed or updates are forced -> [Help 1]
-- sbolla
kubernetes
mysql

1 Answer

4/21/2018

This specific error is because --ignore-db-dir is not specified correctly. = should not be used.

From your logs, the following can be seen

[Server] unknown variable 'ignore-db-dir=lost+found'

Since this fails, the ignore database directory option is not handled correctly.

Ideally, the additional options that I mentioned below should also be part of the yaml file. Parameters like root password should be set.

  args:
    - "--ignore-db-dir"
    - "lost+found"
  env:
    - name: MYSQL_ROOT_PASSWORD
      # change this
      value: yourpassword
  ports:
    - containerPort: 3306
      name: mysql
  volumeMounts:
      # name must match the volume name below
    - name: mysql-persistent-storage
      # mount path within the container
      mountPath: /var/lib/mysql
-- Jeevan Varughese
Source: StackOverflow