Upgrade ghost 5.71.0 with node 18, encountered error

Node 18 prefers ipv6 resolution over ipv4 - you can see this in the error message with the MySQL connection ::1:3306. If your MySQL server isn’t listening on the ipv6 interface then node won’t be able to connect to it.

Quickest fix is probably explicitly specifying for your database host in place of localhost in your Ghost config.