Ignoring invalid configuration option passed to Connection: filename. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection

Using Dockers for Ghost and the log for the Ghost docker shows this error on startup:

Ignoring invalid configuration option passed to Connection: filename. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection

Any ideas?

This reads like a node configuration error. Check your settings for host, user etc.

I also use Ghost with Docker and I have the same warning multiple times in my logs.

[2022-05-11 20:32:38] INFO "GET /assets/images/manifest/manifest-icon-144.png" 200 9ms
Ignoring invalid configuration option passed to Connection: filename. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection
Ignoring invalid configuration option passed to Connection: filename. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection
Ignoring invalid configuration option passed to Connection: filename. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection
Ignoring invalid configuration option passed to Connection: filename. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection
[2022-05-11 20:33:21] INFO "GET /" 200 179ms
Ignoring invalid configuration option passed to Connection: filename. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection
Ignoring invalid configuration option passed to Connection: filename. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection
Ignoring invalid configuration option passed to Connection: filename. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection
Ignoring invalid configuration option passed to Connection: filename. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection
[2022-05-11 20:34:21] INFO "GET /" 200 246ms

I’ currently using Ghost v4.44.0. Here is an excerpt of my docker-compose.yml file:

version: "3.8"

services:
  ghost:
    deploy:
      resources:
        limits:
          cpus: '0.750'
          memory: 256M
        reservations:
          cpus: '0.001'
          memory: 64M
    environment:
      database__client: mysql2
      database__connection__database: ${MARIADB_DATABASE}
      database__connection__host: ${MARIADB_HOSTNAME}
      database__connection__password: ${MARIADB_PASSWORD}
      database__connection__user: ${MARIADB_USERNAME}
      database__pool__min: 0 # https://sigyl.com/git/stack/ghost/src/commit/6a35a57711f9fe3046900b2beb9c4d5e0eca238e/docker-compose.yml?lang=uk-UA
      url: https://${TRAEFIK_SUBDOMAIN}.${TRAEFIK_DOMAIN}/

I’m using MySQL. Are you using MariaDB? That could be the problem as the Ghost team has warned they do not support that.

Either way, same errors on my setup.

What’s in your config.production.json file? It sounds like you have some config in there that isn’t being overridden with your environment variables so the mysql2 client lib is seeing unexpected config options.

I know the config file in my situation didn’t match up with the settings I was installing on the backend of my docker. I use a visual docker installation interface via unraid. Whenever I made changes on Unraid, it seemed to pass those changes through to the docker, so I figured it was fine.

This was it before I altered the settings:

  "url": "http://localhost:2368",
  "server": {
    "port": 2368,
    "host": "::"
  },
  "database": {
    "client": "sqlite3",
    "connection": {
      "filename": "/var/lib/ghost/content/data/ghost.db"
    }
  },
  "mail": {
    "transport": "Direct"
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/lib/ghost/content"
  }
}

Just to prove you and myself wrong (I thought), I decided to manually enter in the correct database information for the config file using nano. Knowing full and well it wasn’t supposed to work.

  "database": {
  "client": "mysql",
  "connection": {
    "host": "192.168.0.167",
    "port": 3307,
    "user": "root",
    "password": "mypassword",
    "database": "mydatabase"
  }
}

Guess what? Now it works without errors and is set to MySQL. :man_facepalming:

Thank you for the suggestion.

I don’t know when the warning is sent to the console, but Ghost currently has code to ensure that the connection file name is not set when using MySQL. Here is an excerpt of the sanitizeDatabaseProperties function, from the core/shared/config/utils.js file:

    if (nconf.get('database:client') === 'mysql2') {
        delete database.connection.filename;
    } else {
        delete database.connection.host;
        delete database.connection.user;
        delete database.connection.password;
        delete database.connection.database;
    }

According to this, the warning should not appear, right?

Users using Ghost docker image should have a config.production.json identical as the default config.development.json file according to

bash-5.1# cat config.production.json 
{
  "url": "http://localhost:2368",
  "server": {
    "port": 2368,
    "host": "::"
  },
  "database": {
    "client": "sqlite3",
    "connection": {
      "filename": "/var/lib/ghost/content/data/ghost.db"
    }
  },
  "mail": {
    "transport": "Direct"
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/lib/ghost/content"
  }
}

Is there a way to link to the core/shared/config/env/config.production.json file instead? I think that would solve the problem.:thinking:

I think I understand what you’re getting at.

My config file does look exactly like the one above.

Yes, I can manually edit it.

Yes, it partially fixes the problem - until, I do a docker update.

Then, it reverts back to the config that you posted above.

So, I’m basically back to square one then.

Thoughts?

Can you provide an override with your environment variables?

database__connection__filename: 

I’ll check… out of town for a few days, but will report when I’m back.

I can add that environment variable database__connection__filename (not sure what it does), what exactly should I put there?

The label database__connection__database is already filled in with my database name. Without that part being correctly, Ghost wouldn’t start.

Thoughts?

Kevin is suggesting to put an empty value for that variable - that way, when the new mysql library looks at the config, it might not complain

Ok. Tried that. Same error.

Anyone have any other thoughts or ideas?

Same issue after upgrading from 4.32.2 to 4.47.4

Now around 75% of my logs in stdout are

Ignoring invalid configuration option passed to Connection: filename. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection

I am using environment variables for the configuration of the MySQL database, and this still clearly works (the site is up).

After reading https://github.com/TryGhost/Ghost/commit/bf6f607f424106c1973b09dd47f62c1b972b2ae6 do we need to update the environment variable to be mysql2?

export database__client=mysql2

Also, it looks like ghost-cli cannot unset a parameter in config.production.json, only set a value. So short of using jq to remove the offending key, I think I am stuck with the warning.

My concern about using it that way is that if I update l, I’ll lose everything.

There shouldn’t be an error message thrown out all along the way.

1 Like

Update with Ghost 5… same problem persists.

Thoughts?

1 Like