Ghost: ERROR: Database version is not recognized on ubuntu14

Created on 9 Sep 2016  路  10Comments  路  Source: TryGhost/Ghost

I followed this tutorial: https://www.digitalocean.com/community/tutorials/how-to-create-a-blog-with-ghost-and-nginx-on-ubuntu-14-04

when i tried to run "npm start --production", i got following error:

test@ubuntu-test-purpose:/home/project/jackieouyang$ sudo npm start --production

> [email protected] start /home/project/jackieouyang
> node index

WARNING: Ghost is attempting to use a direct method to send email.
It is recommended that you explicitly configure an email service.
Help and documentation can be found at http://support.ghost.org/mail.


ERROR: Database version is not recognized

 Error
    at Error.DatabaseVersion (/home/project/jackieouyang/core/server/errors/database-version.js:3:18)
    at /home/project/jackieouyang/core/server/data/schema/versioning.js:35:47
    at tryCatcher (/home/project/jackieouyang/node_modules/knex/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/home/project/jackieouyang/node_modules/knex/node_modules/bluebird/js/main/promise.js:510:31)
    at Promise._settlePromiseAt (/home/project/jackieouyang/node_modules/knex/node_modules/bluebird/js/main/promise.js:584:18)
    at Promise._settlePromises (/home/project/jackieouyang/node_modules/knex/node_modules/bluebird/js/main/promise.js:700:14)
    at Async._drainQueue (/home/project/jackieouyang/node_modules/knex/node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (/home/project/jackieouyang/node_modules/knex/node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/home/project/jackieouyang/node_modules/knex/node_modules/bluebird/js/main/async.js:15:14)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

Technical details:

  • Ghost Version: download today
  • Node Version:4.2.6
  • Browser/OS: ubuntu 14
  • Database: Sqlite version 2.8.17
bug help wanted

Most helpful comment

I'm running the docker 0.11.3 image and I had the same problem.

I was following: https://www.ghostforbeginners.com/migrating-ghost-installation-from-sqlite3-to-mysql/

First I got:

ERROR: Unable to populate database: alter table `posts_tags` add constraint `posts_tags_post_id_foreign` foreign key (`post_id`) references `posts` (`id`) - ER_TABLEACCESS_DENIED_ERROR: REFERENCES command denied to user 'ghost'@'172.19.0.15' for table 'posts'

After restart of the container I got the same error as above.

I fixed it by granting REFERENCES to the user. It wasn't in the above guide. Perhaps it should be updated.

All 10 comments

I am also encountering the same issue on Ghost 0.10.1. I'm using Postgres as database.

Hi @wangbourne & @gelojavonitalla sorry to hear you're having trouble!

I'm having a little look at this, and wondering what the problem might be. Are either of you able to access your database and see what the databaseVersion is set to in the settings table?

That would be super helpful in determining what the correct fix might be, thanks 馃憤

Hi @wangbourne & @gelojavonitalla sorry to hear you're having trouble.

Are either or both of you able to take a look inside your DB and see what is in the value column of the settings table where the key is databaseVersion? I have a feeling it might be an empty string or some other non-numeric value which is confusing the code.

If you could confirm this, it would help us to be 100% certain we have the correct fix, as I am not able to easily reproduce this problem.

Hi @ErisDS, checked my database and there are no rows written on the settings table.

Ghost docker images: 0.10, 0.10.0, 0.10.1 and 0.11 same problem as described when up a fresh install...

Images upgraded from 0.9 works fine.

The settiings table are empty (no data). See docker logs when run a fresh install

[ { sql: 'select * from sqlite_master where type = \'table\' and name = ?',
output: [Function: output],
bindings: [ 'settings' ] } ]
{ method: 'first',
options: {},
bindings: [ 'databaseVersion', 1 ],
sql: 'select "value" from "settings" where "key" = ? limit ?' }

ERROR: Database version is not recognized

Error
at Error.DatabaseVersion (/usr/src/ghost/core/server/errors/database-version.js:3:18)
at /usr/src/ghost/core/server/data/schema/versioning.js:35:47
at tryCatcher (/usr/src/ghost/node_modules/knex/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/usr/src/ghost/node_modules/knex/node_modules/bluebird/js/main/promise.js:510:31)
at Promise._settlePromiseAt (/usr/src/ghost/node_modules/knex/node_modules/bluebird/js/main/promise.js:584:18)
at Promise._settlePromises (/usr/src/ghost/node_modules/knex/node_modules/bluebird/js/main/promise.js:700:14)
at Async._drainQueue (/usr/src/ghost/node_modules/knex/node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (/usr/src/ghost/node_modules/knex/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues as _onImmediate
at processImmediate as _immediateCallback

npm info poststart [email protected]
npm info ok

npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm info prestart [email protected]
npm info start [email protected]

If I delete de ghost.db and restart ghost, the system recreate the database corretly.

Logs:

[ { sql: 'select * from sqlite_master where type = \'table\' and name = ?', output: [Function: output], bindings: [ 'settings' ] } ] Migrations: Creating tables... Migrations: Creating table: posts [ { sql: 'create table if not exists "posts" ("id" integer not null primary key autoincrement, "uuid" varchar(36) not null, "title" varchar(150) not null, "slug" varchar(150) not null, "markdown" text null, "mobiledoc" text null, "html" text null, "image" text null, "featured" boolean not null default \'0\', "page" boolean not null default \'0\', "status" varchar(150) not null default \'draft\', "language" varchar(6) not null default \'en_US\', "visibility" varchar(150) not null default \'public\', "meta_title" varchar(150) null, "meta_description" varchar(200) null, "author_id" integer not null, "created_at" datetime not null, "created_by" integer not null, "updated_at" datetime null, "updated_by" integer null, "published_at" datetime null, "published_by" integer null)', bindings: [] }, { sql: 'create unique index posts_slug_unique on "posts" ("slug")', bindings: [] } ] Migrations: Creating table: users [ { sql: 'create table if not exists "users" ("id" integer not null primary key autoincrement, "uuid" varchar(36) not null, "name" varchar(150) not null, "slug" varchar(150) not null, "password" varchar(60) not null, "email" varchar(254) not null, "image" text null, "cover" text null, "bio" varchar(200) null, "website" text null, "location" text null, "facebook" text null, "twitter" text null, "accessibility" text null, "status" varchar(150) not null default \'active\', "language" varchar(6) not null default \'en_US\', "visibility" varchar(150) not null default \'public\', "meta_title" varchar(150) null, "meta_description" varchar(200) null, "tour" text null, "last_login" datetime null, "created_at" datetime not null, "created_by" integer not null, "updated_at" datetime null, "updated_by" integer null)', bindings: [] }, { sql: 'create unique index users_slug_unique on "users" ("slug")', bindings: [] }, { sql: 'create unique index users_email_unique on "users" ("email")', bindings: [] } ] Migrations: Creating table: roles [ { sql: 'create table if not exists "roles" ("id" integer not null primary key autoincrement, "uuid" varchar(36) not null, "name" varchar(150) not null, "description" varchar(200) null, "created_at" datetime not null, "created_by" integer not null, "updated_at" datetime null, "updated_by" integer null)', bindings: [] } ] Migrations: Creating table: roles_users [ { sql: 'create table if not exists "roles_users" ("id" integer not null primary key autoincrement, "role_id" integer not null, "user_id" integer not null)', bindings: [] } ] Migrations: Creating table: permissions [ { sql: 'create table if not exists "permissions" ("id" integer not null primary key autoincrement, "uuid" varchar(36) not null, "name" varchar(150) not null, "object_type" varchar(150) not null, "action_type" varchar(150) not null, "object_id" integer null, "created_at" datetime not null, "created_by" integer not null, "updated_at" datetime null, "updated_by" integer null)', bindings: [] } ]

And if I stop and drop the image and recreate preserving the old ghost.db even upgrading the version all works fine.

The problem is in the firts run of ghost install

I would suggest deleting your DB and trying again is the best workaround short term. I'm not sure how this could happen, however it is quite probably a timing/promise error.

We're going to be reworking the flow of the database creation & migration code in Ghost 1.0.0, so I'd imagine this bug would go away.

In the meantime, a fix for Ghost 0.11 LTS pull requested to the lts branch would be very much welcomed. The next LTS release is currently planned for 30th September.

This was closed by #7465 / 8761579 and released in 0.11.1. Please try again using this version 馃憤

I'm running the docker 0.11.3 image and I had the same problem.

I was following: https://www.ghostforbeginners.com/migrating-ghost-installation-from-sqlite3-to-mysql/

First I got:

ERROR: Unable to populate database: alter table `posts_tags` add constraint `posts_tags_post_id_foreign` foreign key (`post_id`) references `posts` (`id`) - ER_TABLEACCESS_DENIED_ERROR: REFERENCES command denied to user 'ghost'@'172.19.0.15' for table 'posts'

After restart of the container I got the same error as above.

I fixed it by granting REFERENCES to the user. It wasn't in the above guide. Perhaps it should be updated.

I had the same problem too.
mysql version : Ver 14.14 Distrib 5.7.18 for linux-glibc2.5
ghost version : 0.11.8
config file :
database:{
client:'mysql',
connection:{
host:'127.0.0.1',
user:'ghostuser',
password:'ghostpassword',
database:'ghostdb',
charset:'utf8'
},
debug:false
}

Was this page helpful?
0 / 5 - 0 ratings