TryGhost / Ghost

Independent technology for modern publishing, memberships, subscriptions and newsletters.
https://ghost.org
MIT License
46.92k stars 10.21k forks source link

Invalid database host #14976

Closed secondmanveran closed 2 years ago

secondmanveran commented 2 years ago

Issue Summary

Ghost will not connect to new MySQL 8 database server after updating DB host and password.

Steps to Reproduce

  1. Created new MySQL 8 freestanding DB server to facilitate upgrading to v5
  2. Imported tables from MariaDB server.
  3. Updated config.production.json fields db host and db password
  4. Attempted to restart Ghost
  5. Ghost fails with the following error:

Message: Ghost was able to start, but errored during boot with: Invalid database host.

Expectation was that Ghost would restart correctly using new host and password.

Ghost Version

4.32.0, 4.48.2

Node.js Version

16.13.1

How did you install Ghost?

ghost-cli

Database type

MySQL 8

Browser & OS version

No response

Relevant log / error output

āœ– Restarting Ghost
A GhostError occurred.

Message: Ghost was able to start, but errored during boot with: Invalid database host.
Help: Please double check your database config.

Debug Information:
    OS: Ubuntu, v20.04.4 LTS
    Node Version: v16.13.1
    Ghost Version: 4.32.0
    Ghost-CLI Version: 1.21.0
    Environment: production
    Command: 'ghost restart'

Code of Conduct

daniellockyer commented 2 years ago

@secondmanveran This sounds like a configuration issue. What did you have in your database.connection.host config value and can you connect to it using those credentials?

github-actions[bot] commented 2 years ago

Note from our bot: The needs info label has been added to this issue. Updating your original issue with more details is great, but won't notify us, so please make sure you leave a comment so that we can see when you've updated us.

secondmanveran commented 2 years ago

@daniellockyer

I use the internal network IP for my database server.

 "database": {
   "client": "mysql",
   "connection": {
     "host": "192.168.***.***",
     "user": "****",
     "password": "****",
     "database": "ghost_blog"
   }
 },

Same exact setup that was being used for version 4.32, but I had to turn up a new server since the version 5 only accepts MySQL 8, my previous server was MariaDB 10.6.

daniellockyer commented 2 years ago

Hey @secondmanveran - very odd. Are you sure your MySQL instance can be connected to from where you're running Ghost? Is there possibly a firewall in action?

ErisDS commented 2 years ago

I'm going to close this as the lack of similar reports means it probably an environment issue, better suited to the forum if @secondmanveran wants to dig in further to what has happened.

github-actions[bot] commented 2 years ago

Hey @secondmanveran šŸ‘‹

We've reviewed your bug report and believe the issue is environment specific, rather than a bug. Many questions can be answered by reviewing our documentation. If you can't find an answer then our forum is a great place to get community support, plus it helps create a central location for searching problems/solutions.

marianstiehler commented 2 years ago

I have the same issue on Digital Ocean.

secondmanveran commented 2 years ago

@marianstiehler

I have access to the private IP since my ghost server and my db server are in the same network.

Prior to the change to MySQL 8 I could use that private 192.* IP

But for whatever reason Ghost won't recognize this as a valid host anymore. I can use these with other node apps and my Laravel apps, but Ghost blows up.

So I just switched to the public IP and made sure my firewall was open on 3306 and it resolved.

I don't know if this will help you, but it resolved the connection issue.

DennisYildirim commented 1 year ago

Hey @secondmanveran šŸ‘‹

We've reviewed your bug report and believe the issue is environment specific, rather than a bug. Many questions can be answered by reviewing our documentation. If you can't find an answer then our forum is a great place to get community support, plus it helps create a central location for searching problems/solutions.

Can you expand on that environment issue ? I'm facing with the same error on synology nas : Have two containers they can ping each other. have no issues with db or password. but still having the same issue.

DennisYildirim commented 1 year ago

@marianstiehler

I have access to the private IP since my ghost server and my db server are in the same network.

Prior to the change to MySQL 8 I could use that private 192.* IP

But for whatever reason Ghost won't recognize this as a valid host anymore. I can use these with other node apps and my Laravel apps, but Ghost blows up.

So I just switched to the public IP and made sure my firewall was open on 3306 and it resolved.

I don't know if this will help you, but it resolved the connection issue.

Hmm in my case, even when i take down the entire firewall it simply wont connect. I believe this is simply a Synology overall settings interfering with this ghost-db relation. Did anyone bother to solve it ? Or the ghost guys simply wont care nas users to make use of this app ?

It works perfectly fine on my PC but wont work on the synology thing somehow.

rubnov commented 1 year ago

Facing the same issue: ERROR Invalid database host. running ghost:5.47.2 in docker container on production. Here's my docker-compose.yml:

version: '3.8'
volumes:
  mysql-volume:
  ghost-volume-en:

services:

 ghost:
  image: ghost:5.47.2
  volumes:
    - ghost-volume:/var/lib/ghost/content
    # localized copy of casper theme
    - ./casper:/var/lib/ghost/content/themes/casper
  restart: always
  ports:
    - 2368:2368
  environment:
    url: [REDACTED]
    database__client: mysql
    database__connection__host: mysql
    database__connection__user: bloguser
    database__connection__password: [REDACTED]
    database__connection__database: en_schema
  depends_on:
    - mysql

mysql:  
  image: mysql:8.0
  volumes:
    - mysql-volume:/var/lib/mysql
  environment:
    MYSQL_ROOT_PASSWORD: [REDACTED]
    MYSQL_USER: bloguser
    MYSQL_PASSWORD: [REDACTED]
  entrypoint:
    sh -c "
      echo 'CREATE DATABASE IF NOT EXISTS en_schema; GRANT ALL PRIVILEGES ON en_schema.* TO '\''bloguser'\''; ' > /docker-entrypoint-initdb.d/init.sql;
      echo 'CREATE DATABASE IF NOT EXISTS de_schema; GRANT ALL PRIVILEGES ON de_schema.* TO '\''bloguser'\''; ' >> /docker-entrypoint-initdb.d/init.sql;
      echo 'CREATE DATABASE IF NOT EXISTS fr_schema; GRANT ALL PRIVILEGES ON fr_schema.* TO '\''bloguser'\''; ' >> /docker-entrypoint-initdb.d/init.sql;
      /usr/local/bin/docker-entrypoint.sh --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --default-authentication-plugin=mysql_native_password
    "
mlavelle42 commented 11 months ago

Did you resolve this issue?

secondmanveran commented 11 months ago

Sure.

To be honest I don't remember.