Updating Ghost from MySql 5 to 8

I recently updated my Ghost blogging software, and ran into some trouble regarding the MySql update. I think this was because I was updating Ghost, MySql, and Ubuntu all at the same time. Here's what fixed it for me.

First off, the big thing to learn is that MySql 8 changes the default collation of UTF8 – this caused some issues with upgrading, and downgrading the collation default seemed to fix it. It was kind of fiddly, but here's how I did it:

  1. Upgrade to MySql 8
    I did this by upgrading Ubuntu to a new LTS version.
  2. Reset the default collation
    I did this in the MySql conf file, /etc/mysql/my.cnf file:
[mysqld]
init_connect='SET default_collation_for_utf8mb4=utf8mb4_general_ci'
  1. Verify the collation setting
    $ mysql -u root -p -e 'use mysql; SELECT @@default_collation_for_utf8mb4'
    This should return utf8mb4_general_ci
  2. Install Ghost
    After this collation setting was reverted to the old version, Ghost installed properly.