Ghost CLI fails setting up "ghost" mysql user

I’m trying to install Ghost on a rented VM but the installation keeps failing when trying to setup the ghost mysql user.

+------------------+
| User             |
+------------------+
| debian-sys-maint |
| mysql.infoschema |
| mysql.session    |
| mysql.sys        |
| root             |
+------------------+

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
  • Using netstat -tln, I confirmed that mysql is listening on port 3306:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:33060         0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 :::80                   :::*                    LISTEN
tcp6       0      0 :::443                  :::*                    LISTEN
  • Output of ghost setup is:
? Enter your blog URL: https://blog.myurl.com
? Enter your MySQL hostname: localhost
? Enter your MySQL username: root
? Enter your MySQL password (skip to keep current password): [hidden]
? Enter your Ghost database name: myurl_prod
✔ Configuring Ghost
+ sudo chown -R ghost:ghost /var/www/myurl/content
✔ Setting up "ghost" system user
? Do you wish to set up "ghost" mysql user? Yes
✖ Setting up "ghost" mysql user
Nginx configuration already found for this url. Skipping Nginx setup.
ℹ Setting up Nginx [skipped]
Nginx setup task was skipped, skipping SSL setup
ℹ Setting up SSL [skipped]
Systemd service has already been set up. Skipping Systemd setup
ℹ Setting up Systemd [skipped]
+ sudo systemctl is-active ghost_blog-myurl-com
+ sudo systemctl reset-failed ghost_blog-myurl-com
? Do you want to start Ghost? Yes
+ sudo systemctl start ghost_blog-myurl-com
+ sudo systemctl stop ghost_blog-myurl-com
✖ Starting Ghost
One or more errors occurred.

1) ConfigError

Error detected in the production configuration.

Message: connect ECONNREFUSED ::1:3306
Configuration Key(s): database.connection.host / database.connection.port
Current Value(s): localhost / 3306

Help: Ensure that MySQL is installed and reachable. You can always re-run `ghost setup` to try again.


2) GhostError

Message: Ghost was able to start, but errored during boot with: connect ECONNREFUSED ::1:3306
Help: Unknown database error
Suggestion: journalctl -u ghost_blog-myurl-com -n 50

Debug Information:
    OS: Ubuntu, v22.04.3 LTS
    Node Version: v18.17.1
    Ghost Version: 5.61.3
    Ghost-CLI Version: 1.24.2
    Environment: production
    Command: 'ghost setup'
  • Output of ghost doctor:
✔ Checking system Node.js version - found v18.17.1
✔ 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_blog-myurl-com
+ sudo systemctl reset-failed ghost_blog-myurl-com
✔ Validating config
✔ 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 v18.17.1
  • Contents of my config.production.json:
{
  "url": "https://blog.myurl.com",
  "server": {
    "port": 2368,
    "host": "127.0.0.1"
  },
  "database": {
    "client": "mysql",
    "connection": {
      "host": "localhost",
      "port": 3306,
      "user": "root",
      "password": "mypassword",
      "database": "myurl_prod"
    }
  },
  "mail": {
    "transport": "Direct"
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/www/myurl/content"
  },
  "bootstrap-socket": {
    "port": 8000,
    "host": "localhost"
  }
}

Any help would be very much appreciated!

1 Like

Don’t use root, create a database user for Ghost instead. Most likely, root access requires authentication by socket.

1 Like