Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

248
Views
mysql: unknown option '--"' in Kubernetes

I am trying to run mysql 5.7 in kubernetes and got this error mysql: unknown option '--"'

My database.yaml looks like this

apiVersion: v1
kind: Pod
metadata:
  name: app-db
  labels:
    app: app-db
spec:
  containers:
  - name: mysql
    image: mysql:5.7
    ports:
    - name: mysql-port
      containerPort: 3306
    env:
    - name: MYSQL_ROOT_PASSWORD
      valueFrom:
        secretKeyRef:
          name: app-secrets
          key: rootPassword
    - name: MYSQL_USER
      valueFrom:
        secretKeyRef:
          name: app-secrets
          key: username
    - name: MYSQL_ROOT_PASSWORD
      valueFrom:
        secretKeyRef:
          name: app-secrets
          key: password
    - name: MYSQL_DATABASE
      valueFrom:
        secretKeyRef:
          name: app-secrets
          key: defaultDatabase

Maybe I missed something?

I tried to switch versions, tried to use samples from the official Kubernetes site - nothing works for me.

The last logs with error:

2020-07-19 20:51:01 100 [Note] Event Scheduler: Loaded 0 events
2020-07-19 20:51:01 100 [Note] mysqld: ready for connections.
Version: '5.6.49'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server (GPL)
2020-07-19 20:51:01+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
2020-07-19 20:51:04 100 [Warning] 'proxies_priv' entry '@ root@app-db' ignored in --skip-name-resolve mode.
2020-07-19 20:51:04+00:00 [Note] [Entrypoint]: Creating database app_db

mysql: unknown option '--"'
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

I ran into the same issue and after a lot of frustrating debugging I finally solved it.

The problem was that I created my secrets with the echo 'secret' | base64 command and the echo command automatically inserts a trailing newline.

Use echo -n 'secret' | base64 instead. ✔️

Unfortunately this was not at all what I expected and therefore I didn't notice that there was a line break in the log output. Hopefully this can help some people who also use the echo command to encode to base64.

over 4 years ago · Santiago Trujillo Report

0

I looked at the entrypont.sh script for this container 👀. And the error is happening here in the 'Creating database' section:

# Creates a custom database and user if specified
if [ -n "$MYSQL_DATABASE" ]; then
        mysql_note "Creating database ${MYSQL_DATABASE}" 👈
        docker_process_sql --database=mysql <<<"CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` ;" 👈
fi

if [ -n "$MYSQL_USER" ] && [ -n "$MYSQL_PASSWORD" ]; then
         mysql_note "Creating user ${MYSQL_USER}"
...
docker_process_sql() {
        passfileArgs=()
        if [ '--dont-use-mysql-root-password' = "$1" ]; then
                passfileArgs+=( "$1" )
                shift
        fi
        # args sent in can override this db, since they will be later in the command
        if [ -n "$MYSQL_DATABASE" ]; then
                set -- --database="$MYSQL_DATABASE" "$@"
        fi

        mysql --defaults-extra-file=<( _mysql_passfile "${passfileArgs[@]}") --protocol=socket -uroot -hlocalhost --socket="${SOCKET}" "$@"
}

I also tested with plain docker and it works fine with this:

docker run --name some-mysql -d -e MYSQL_ROOT_PASSWORD=my-secret-pw -e MYSQL_DATABASE="app" -e MYSQL_USER="user1" mysql:5.7

So most likely there is something corrupted in your secrets 💀.

✌️

over 4 years ago · Santiago Trujillo Report

0

The YAML configuration is quite simple. I guess the problem might lie in the app-secrets.

Please disable all envs and then add one by one, which could help you find out the problem settings.

In case your secrets are not correct, you can set env directly, such as:

env:
  - name: MYSQL_ROOT_PASSWORD
    value: somePassYouLike

Because many add Kubernetes secrets by copying manually generated base64. Make sure no spaces after the base64 string itself copied. Go to Kubernetes dashboard to check the length of the secrets.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!