Ghost error, showing mysql not installed

If you’re looking for help, please provide information about your environment. If you delete this template and don’t provide any information, your topic will be automatically closed. I tried multiple times, but the issue persists. I’ve provided the output for ghost doctor as well.

While trying tp update Ghost to 5.0, this is the error I’m facing

And

  • How was Ghost installed and configured? Using DO instance
  • What Node version, database, OS & browser are you using? Node - v16.15.0, mysql8, Ubuntu, v20.04.4 LTS
  • What errors or information do you see in the console?
ℹ Downloading and updating Ghost [skipped]
Knex: run
$ npm install mysql --save
Cannot find module 'mysql'
Require stack:
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/dialects/mysql/index.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/dialects/index.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/knex-builder/internal/config-resolver.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/knex-builder/Knex.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/index.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/knex.js
- /usr/lib/node_modules/ghost-cli/lib/tasks/major-update/data.js
- /usr/lib/node_modules/ghost-cli/lib/tasks/major-update/ui.js
- /usr/lib/node_modules/ghost-cli/lib/tasks/major-update/index.js
- /usr/lib/node_modules/ghost-cli/lib/commands/update.js
- /usr/lib/node_modules/ghost-cli/lib/bootstrap.js
- /usr/lib/node_modules/ghost-cli/bin/ghost
Error: Cannot find module 'mysql'
Require stack:
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/dialects/mysql/index.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/dialects/index.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/knex-builder/internal/config-resolver.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/knex-builder/Knex.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/index.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/knex.js
- /usr/lib/node_modules/ghost-cli/lib/tasks/major-update/data.js
- /usr/lib/node_modules/ghost-cli/lib/tasks/major-update/ui.js
- /usr/lib/node_modules/ghost-cli/lib/tasks/major-update/index.js
- /usr/lib/node_modules/ghost-cli/lib/commands/update.js
- /usr/lib/node_modules/ghost-cli/lib/bootstrap.js
- /usr/lib/node_modules/ghost-cli/bin/ghost
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Client_MySQL._driver (/var/www/ghost/versions/5.1.0/node_modules/knex/lib/dialects/mysql/index.js:23:12)
    at Client_MySQL.initializeDriver (/var/www/ghost/versions/5.1.0/node_modules/knex/lib/client.js:190:26)
    at new Client (/var/www/ghost/versions/5.1.0/node_modules/knex/lib/client.js:75:12)
    at new Client_MySQL (/var/www/ghost/versions/5.1.0/node_modules/knex/lib/dialects/mysql/index.js:21:1)
    at knex (/var/www/ghost/versions/5.1.0/node_modules/knex/lib/knex-builder/Knex.js:16:28)
    at getData (/usr/lib/node_modules/ghost-cli/lib/tasks/major-update/data.js:22:24)
    at Task.ui [as task] (/usr/lib/node_modules/ghost-cli/lib/tasks/major-update/ui.js:35:48)
    at /usr/lib/node_modules/ghost-cli/node_modules/listr/lib/task.js:167:30
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
✖ Updating to a major version
An error occurred.
Message: 'Knex: run
$ npm install mysql --save
Cannot find module 'mysql'
Require stack:
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/dialects/mysql/index.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/dialects/index.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/knex-builder/internal/config-resolver.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/knex-builder/Knex.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/index.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/knex.js
- /usr/lib/node_modules/ghost-cli/lib/tasks/major-update/data.js
- /usr/lib/node_modules/ghost-cli/lib/tasks/major-update/ui.js
- /usr/lib/node_modules/ghost-cli/lib/tasks/major-update/index.js
- /usr/lib/node_modules/ghost-cli/lib/commands/update.js
- /usr/lib/node_modules/ghost-cli/lib/bootstrap.js
- /usr/lib/node_modules/ghost-cli/bin/ghost'

Info from logs

Debug Information:
    OS: Ubuntu, v20.04.4 LTS
    Node Version: v16.15.0
    Ghost Version: 4.48.0
    Ghost-CLI Version: 1.19.2
    Environment: production
    Command: 'ghost update'
An error occurred.
Message: 'Knex: run
$ npm install mysql --save
Cannot find module 'mysql'
Require stack:
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/dialects/mysql/index.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/dialects/index.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/knex-builder/internal/config-resolver.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/knex-builder/Knex.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/index.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/knex.js
- /usr/lib/node_modules/ghost-cli/lib/tasks/major-update/data.js
- /usr/lib/node_modules/ghost-cli/lib/tasks/major-update/ui.js
- /usr/lib/node_modules/ghost-cli/lib/tasks/major-update/index.js
- /usr/lib/node_modules/ghost-cli/lib/commands/update.js
- /usr/lib/node_modules/ghost-cli/lib/bootstrap.js
- /usr/lib/node_modules/ghost-cli/bin/ghost'

Stack: Error: Knex: run
$ npm install mysql --save
Cannot find module 'mysql'
Require stack:
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/dialects/mysql/index.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/dialects/index.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/knex-builder/internal/config-resolver.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/knex-builder/Knex.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/lib/index.js
- /var/www/ghost/versions/5.1.0/node_modules/knex/knex.js
- /usr/lib/node_modules/ghost-cli/lib/tasks/major-update/data.js
- /usr/lib/node_modules/ghost-cli/lib/tasks/major-update/ui.js
- /usr/lib/node_modules/ghost-cli/lib/tasks/major-update/index.js
- /usr/lib/node_modules/ghost-cli/lib/commands/update.js
- /usr/lib/node_modules/ghost-cli/lib/bootstrap.js
- /usr/lib/node_modules/ghost-cli/bin/ghost
    at Client_MySQL.initializeDriver (/var/www/ghost/versions/5.1.0/node_modules/knex/lib/client.js:194:13)
    at new Client (/var/www/ghost/versions/5.1.0/node_modules/knex/lib/client.js:75:12)
    at new Client_MySQL (/var/www/ghost/versions/5.1.0/node_modules/knex/lib/dialects/mysql/index.js:21:1)
    at knex (/var/www/ghost/versions/5.1.0/node_modules/knex/lib/knex-builder/Knex.js:16:28)
    at getData (/usr/lib/node_modules/ghost-cli/lib/tasks/major-update/data.js:22:24)
    at Task.ui [as task] (/usr/lib/node_modules/ghost-cli/lib/tasks/major-update/ui.js:35:48)
    at /usr/lib/node_modules/ghost-cli/node_modules/listr/lib/task.js:167:30
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Ghost Doctor

✔ Checking system Node.js version - found v16.15.0
✔ Checking logged in user
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking system compatibility
✔ Checking for a MySQL installation
+ sudo systemctl is-active ghost_healthvery-com
Instance is currently running
ℹ Validating config [skipped]
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability
✔ Checking binary dependencies
✔ Checking free space
✔ Checking systemd unit file
✔ Checking systemd node version - found v16.15.0
1 Like

In the version folder, npm install mysql --force solved it.
It won’t install otherwise due to dependencies issue.

@haikukoten
I have the same problem. Have you solved it by using this command in ghost installation folder?

npm install mysql --force

problem solved by updating Ghost CLI

1 Like

Can confirm, you should upgrade your ghost-cli and retry first before attempting a force install.

# On a production server using a non-root user:
sudo npm install -g ghost-cli@latest