MariaDB connection issues

I’m having a problem starting Ghost on my Raspberry Pi. It’s always worked until recently when I’ve started getting an error with MariaDB.

Ghost-CLI version: 1.15.3
URL: Corballis.co.uk [not that you can get there due to the error described below]
Ghost version: 3.0

Configuration:
OS: Raspbian GNU/Linux, v9
Node Version: v10.16.0
Ghost-CLI Version: 1.15.3
Environment: production
Command: ‘ghost update’
mysql Ver 15.1 Distrib 10.1.23-MariaDB, for debian-linux-gnueabihf (armv7l) using readline 5.2

Note, Ghost Update fails with:

An error occurred.
Message: ‘Invalid Version: null’

  • How was Ghost installed and configured? Via npm.
  • No browser - running headless, I log in via ssh
  • What errors or information do you see in the console? See below
  • What steps could someone else take to reproduce the issue you’re having? Not sure

Error message
MariaDB connect ECONNREFUSED 127.0.0.1:3306 Error ID: 500 Error Code: ECONNREFUSED
and, also:
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2 “No such file or directory”)

Here’s the output from Ghost Doctor:

tc@my-pi:/var/www/xxxxx.com $ ghost doctor

:heavy_check_mark: Checking system Node.js version

:heavy_check_mark: Checking logged in user

:heavy_check_mark: Ensuring user is not logged in as ghost user

:heavy_check_mark: Checking if logged in user is directory owner

:heavy_check_mark: Checking current folder permissions

System checks failed with message: ‘Linux version is not Ubuntu 16, 18, or 20’
Some features of Ghost-CLI may not work without additional configuration.
For local installs we recommend using ghost install local instead.
? Continue anyway? Yes
System stack check skipped

:information_source: Checking system compatibility [skipped]
:heavy_check_mark: Checking for a MySQL installation

  • sudo systemctl is-active ghost_undefined
  • sudo systemctl reset-failed ghost_undefined
    :heavy_check_mark: Validating config
    :heavy_check_mark: Checking folder permissions
    :heavy_check_mark: Checking file permissions
    :heavy_check_mark: Checking content folder ownership
    :heavy_check_mark: Checking memory availability
    :heavy_check_mark: Checking binary dependencies
    :heavy_check_mark: Checking free space

This is from my database log:

Dec 24 12:44:10 my-pi node[7182]: [2020-12-24 11:44:10] WARN Retrying…
Dec 24 12:44:10 my-pi node[7182]: [2020-12-24 11:44:10] WARN Can’t connect to the bootstrap socket (localhost 8000) ECONNREFUSED.
Dec 24 12:44:10 my-pi node[7182]: [2020-12-24 11:44:10] WARN Tries: 2
Dec 24 12:44:10 my-pi node[7182]: [2020-12-24 11:44:10] WARN Retrying…
Dec 24 12:44:10 my-pi node[7182]: [2020-12-24 11:44:10] WARN Can’t connect to the bootstrap socket (localhost 8000) ECONNREFUSED.
Dec 24 12:44:10 my-pi node[7182]: [2020-12-24 11:44:10] ERROR connect ECONNREFUSED 127.0.0.1:3306
Dec 24 12:44:10 my-pi node[7182]:
Dec 24 12:44:10 my-pi node[7182]: connect ECONNREFUSED 127.0.0.1:3306
Dec 24 12:44:10 my-pi node[7182]: “Unknown database error”
Dec 24 12:44:10 my-pi node[7182]: Error ID:
Dec 24 12:44:10 my-pi node[7182]: 500
Dec 24 12:44:10 my-pi node[7182]: Error Code:
Dec 24 12:44:10 my-pi node[7182]: ECONNREFUSED
Dec 24 12:44:10 my-pi node[7182]: ----------------------------------------
Dec 24 12:44:10 my-pi node[7182]: DatabaseError: connect ECONNREFUSED 127.0.0.1:3306
Dec 24 12:44:10 my-pi node[7182]: at DatabaseError.KnexMigrateError (/var/www/xxxxxx.com/versions/3.34.0/node_modules/knex-migrator/lib/errors.js:7:26)
Dec 24 12:44:10 my-pi node[7182]: at new DatabaseError (/var/www/xxxxxx.com/versions/3.34.0/node_modules/knex-migrator/lib/errors.js:55:26)
Dec 24 12:44:10 my-pi node[7182]: at connection.raw.catch (/var/www/xxxxxx.com/versions/3.34.0/node_modules/knex-migrator/lib/database.js:47:19)
Dec 24 12:44:10 my-pi node[7182]: Error: connect ECONNREFUSED 127.0.0.1:3306
Dec 24 12:44:10 my-pi node[7182]: at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1106:14)
Dec 24 12:44:10 my-pi node[7182]: --------------------
Dec 24 12:44:10 my-pi node[7182]: at Protocol._enqueue (/var/www/xxxxxx.com/versions/3.34.0/node_modules/mysql/lib/protocol/Protocol.js:144:48)
Dec 24 12:44:10 my-pi node[7182]: at Protocol.handshake (/var/www/xxxxxx.com/versions/3.34.0/node_modules/mysql/lib/protocol/Protocol.js:51:23)
Dec 24 12:44:10 my-pi node[7182]: at Connection.connect (/var/www/xxxxxx.com/versions/3.34.0/node_modules/mysql/lib/Connection.js:116:18)
Dec 24 12:44:10 my-pi node[7182]: at Promise (/var/www/xxxxxx.com/versions/3.34.0/node_modules/knex-migrator/node_modules/knex/lib/dialects/mysql/index.js:69:18)
Dec 24 12:44:10 my-pi node[7182]: at Promise._execute (/var/www/xxxxxx.com/versions/3.34.0/node_modules/bluebird/js/release/debuggability.js:384:9)
Dec 24 12:44:10 my-pi node[7182]: at Promise._resolveFromExecutor (/var/www/xxxxxx.com/versions/3.34.0/node_modules/bluebird/js/release/promise.js:518:18)
Dec 24 12:44:10 my-pi node[7182]: at new Promise (/var/www/xxxxxx.com/versions/3.34.0/node_modules/bluebird/js/release/promise.js:103:10)
Dec 24 12:44:10 my-pi node[7182]: at Client_MySQL.acquireRawConnection (/var/www/xxxxxx.com/versions/3.34.0/node_modules/knex-migrator/node_modules/knex/lib/dialects/mysql/index.js:64:12)
Dec 24 12:44:10 my-pi node[7182]: at create (/var/www/xxxxxx.com/versions/3.34.0/node_modules/knex-migrator/node_modules/knex/lib/client.js:291:39)
Dec 24 12:44:10 my-pi node[7182]: at process._tickCallback (internal/process/next_tick.js:68:7)
Dec 24 12:44:10 my-pi node[7182]: at Function.Module.runMain (internal/modules/cjs/loader.js:832:11)
Dec 24 12:44:10 my-pi node[7182]: at startup (internal/bootstrap/node.js:283:19)
Dec 24 12:44:10 my-pi node[7182]: at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Dec 24 12:44:10 my-pi node[7182]:
Dec 24 12:44:11 my-pi node[7182]: /usr/lib/node_modules/ghost-cli/lib/process-manager.js:52
Dec 24 12:44:11 my-pi node[7182]: throw error;
Dec 24 12:44:11 my-pi node[7182]: ^
Dec 24 12:44:11 my-pi node[7182]: [object Object]
Dec 24 12:44:11 my-pi systemd[1]: ghost_corballis-co-uk.service: Main process exited, code=exited, status=1/FAILURE
Dec 24 12:44:11 my-pi systemd[1]: ghost_corballis-co-uk.service: Unit entered failed state.
Dec 24 12:44:11 my-pi systemd[1]: ghost_corballis-co-uk.service: Failed with result ‘exit-code’.
Dec 24 12:44:11 my-pi systemd[1]: ghost_corballis-co-uk.service: Service hold-off time over, scheduling restart.
Dec 24 12:44:11 my-pi systemd[1]: Stopped Ghost systemd service for blog: corballis-co-uk.
– Subject: Unit ghost_corballis-co-uk.service has finished shutting down
– Defined-By: systemd
– Support: Debian -- Support

Okay, I solved this one by

  1. fixing a load of broken symlinks
  2. rewriting the nginx configuration file
  3. changing the ownership on the /tmp/ structure being used for installation to match that of the install
  4. then following the instructions here:
    "ER_TOO_LONG_KEY: Specified key was too long" false error · Issue #51 · TryGhost/knex-migrator · GitHub