简体   繁体   中英

Initialize Ghost database on new install

I am trying to set up a brand new Ghost blog on a Centos 7 server. I have Nginx, Node and Ghost installed and have written all of the necessary configuration files. It's pretty close to working, but I wanted to use MySQL instead of SQLite, so I created a new (blank) MySQL database called "ghost_db", set up a MySQL user called "ghost", gave the user permission for the database, and added these lines to config.js:

    database: {
  client: 'mysql',
  connection: {
    host: 'localhost',
    user: 'ghost',
    password: 'mypassword',
    database: 'ghost_db'
    charset: 'utf8'
    filename: path.join(__dirname, '/content/data/ghost-dev.db')
  },
  debug: false
}, ...

When I try to start it, I get an error that suggests I use knex-migrator to initialize the database.

[john@a ghost]$ npm start

> ghost@1.18.4 start /var/www/ghost
> node index
[2017-12-10 00:08:00] ERROR
NAME: DatabaseIsNotOkError
CODE: MIGRATION_TABLE_IS_MISSING
MESSAGE: Please run knex-migrator init ...

However, some comments on Stackexchange suggest that using knex-migrate may be unnecessary for this version of Ghost, and when I run knex-migrator, it also fails:

[john@a ghost]$ knex-migrator init
[2017-12-09 16:21:33] ERROR

NAME: RollbackError
CODE: SQLITE_ERROR
MESSAGE: delete from "migrations" where "name" = '2-create-fixtures.js' and "version" = 'init' and "currentVersion" = '1.18' - SQLITE_ERROR: no such table: migrations
...[omitted] 
Error: SQLITE_ERROR: no such table: migrations

I think the problem may be that the "ghost_db" database I initially created is blank. The "ghost-dev.db" file that is pointed to in the config.js seems to be for SQLite, but I get the same error message if I switch config.js back to using an SQLite database. I don't know what the "migrations" table is. I found the schema that I think Ghost expects at [ https://github.com/TryGhost/Ghost/blob/1.16.2/core/server/data/schema/schema.js] , but I'm not sure how to use that to initialize the tables, etc., except for doing it very laboriously by hand. I'm stumped!

I took an alternate approach which proved successful, which was to install Ghost as an NPM module. The official Ghost instructions label this as an "advanced" process, but it wasn't too difficult to follow the instructions in the excellent nehalist.io and Stickleback blogs. There was also some useful guidance on the HugeServer knowledgebase. I think ultimately the problem was that the Ghost commandline interface (ghost-cli) wasn't designed for Centos 7.

Knex-migrator is new in Ghost 1.0, which also uses a config.<env>.json file for configuration.

It sounds like you added your database config into a file called config.js which was correct <1.0, however it seems you were installing Ghost 1.0 and therefore your new connection details would have needed to live in config.production.json .

You are correct that Ghost-CLI isn't intended for use on CentOS (it's for Ubuntu), but I'd be very surprised if it failed to install Ghost correctly. The issues with other OSs are mainly in the subtle differences between systemd ie keeping Ghost running.

对我来说,答案是根本不创建数据库,而让Ghost作为ghost install一部分进行操作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM