Recently, I finally managed to upgrade my old Ghost instance running the 4.x.x release on SQLite to the latest 5.x.x release on MySQL.
I had attempted this upgrade multiple times without success, but now everything works perfectly. Here’s how I did it:
- Backup everything, just in case.
- Upgrade to version
5.8.3
. AFAIK this is the latest version that still supports SQLite. - Set up a fresh MySQL instance.
- Create the database and user.
- Create a database named
ghost
. - Create a user
ghost
with the appropriate permissions for theghost
database. - Use the collation
utf8mb4_0900_ai_ci
for the database.
- Create a database named
- Modify your
config.production.json
file to point to the new MySQL instance:
"database": {
"client": "mysql",
"connection": {
"host": "your-mysql-host.domain.com",
"user": "ghost",
"password": "password",
"database": "ghost",
}
},
- Restart Ghost. Ghost will run migrations on the new database and create the required tables.
- Download the
ghost.db
SQLite database file from your Ghost instance. - Download and install the sqlite3-to-mysql tool.
- Run
sqlite3mysql --sqlite-file 'ghost.db' --mysql-host your-mysql-host.domain.com --mysql-user ghost --mysql-database ghost --mysql-skip-create-tables --without-foreign-keys --mysql-truncate-tables
. This tool will populate your MySQL database using the backup. - Restart Ghost, Check that everything is running smoothly.
- Perform incremental upgrades. I didn’t attempt to upgrade in one leap. Instead, I upgraded in steps:
5.8.3
→5.39.0
→5.57.2
→5.76.1
→5.105.0
- …
- PROFIT!
I know the official guides recommend a full reinstall, but I preferred avoiding the hassle of dealing with media files and other settings.
Hope this helps!