Migrating Ghost Installation From SQLite3 To MySQL

If you have a Ghost blog with a SQLite3 backend and want to migrate to MySQL, you can use this simple process:

  1. To get started you will need to have MySQL installed on your server:
  2. Ubuntu
    apt-get install mysql-server
    yum install mysql-server
  3. Go through the MySQL setup
  4. mysql_secure_installation
  5. Next log into MySQL database as the root user (note that there is no space between the -p and your password):
  6. mysql -u root -p{your password}
  7. Create the database for Ghost:
  8. create database ghost;
  9. Create a user for your Ghost blog:
  10. CREATE USER 'ghost'@'localhost' IDENTIFIED BY 'password';
  11. Grant Ghost user access to the Ghost database
  12. grant create,delete,insert,select,update,alter ON ghost.* TO 'ghost'@'localhost';
  13. And now flush the newly granted privileges
  14. flush privileges;
  15. Now that MySQL is all setup you need to do a backup of your current Ghost content. Go to yoursite.com/ghost/debug and do an export of your Ghost blog.
  16. Now you need to stop Ghost and edit your config.js file.
  17. In your config.js file switch the database stanza, in the production section, to the following:
    database: {
        client: 'mysql',
        connection: {
            host: 'localhost',
            user: 'database username',
            password: 'database user password',
            database: 'database name',
            charset: 'utf8'
         debug: true
    Replace the database username database user password database name with the specifics you used while setting up MySQL.
  18. Now start Ghost and go to yoursite.com/ghost. You will not be logged in anymore and your previous user account will not work. Create a temporary user to get logged in. Now go to yoursite.com/ghost/debug and import your previously exported Ghost backup.

Now all of your Ghost content has been imported into the MySQL database!