New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get through mysql setting while installing Ghost via CLI #407

Open
vistaing opened this Issue Jul 31, 2017 · 10 comments

Comments

4 participants
@vistaing

vistaing commented Jul 31, 2017

SOLVED!

I'm trying to migrate from 0.11.11 to 1.0.0+, and I followed the official guide here. To complete this, I started a brand new droplet on DigitalOcean.

The problem is that I just can't pass the systemd setting step. Here's detailed log:


? Enter your blog URL: http://shi****yu.com/
? Enter your MySQL hostname: localhost
? Enter your MySQL username: recon
? Enter your MySQL password (skip to keep current password): [hidden]
? Enter your Ghost database name: ghost_production
✔ Configuring Ghost
✔ Setting up instance
Running sudo command: chown -R ghost:ghost /var/www/ghost/content
✔ Setting up "ghost" system user
? Do you wish to set up Nginx? Yes
✔ Creating nginx config file at /var/www/ghost/system/files/shiratsuyu.com.conf
Running sudo command: ln -sf /var/www/ghost/system/files/shiratsuyu.com.conf /etc/nginx/sites-available/shiratsuyu.com.conf
Running sudo command: ln -sf /etc/nginx/sites-available/shiratsuyu.com.conf /etc/nginx/sites-enabled/shiratsuyu.com.conf
Running sudo command: service nginx restart
✔ Setting up Nginx
? Do you wish to set up SSL? Yes
? Enter your email (used for Let's Encrypt notifications) ****@.com
✔ Creating ssl security parameters file at /var/www/ghost/system/files/ssl-params.conf
✔ Creating ssl config file at /var/www/ghost/system/files/shiratsuyu.com-ssl.conf
Running sudo command: ln -sf /var/www/ghost/system/files/shiratsuyu.com-ssl.conf /etc/nginx/sites-available/shiratsuyu.com-ssl.conf
Running sudo command: ln -sf /etc/nginx/sites-available/shiratsuyu.com-ssl.conf /etc/nginx/sites-enabled/shiratsuyu.com-ssl.conf
Running sudo command: service nginx restart
✔ Setting up SSL
? Do you wish to set up "ghost" mysql user? Yes
MySQL user is not "root", skipping additional user setup
ℹ Setting up "ghost" mysql user [skipped]
? Do you wish to set up Systemd? Yes
✔ Creating systemd service file at /var/www/ghost/system/files/ghost_localhost.service
Running sudo command: ln -sf /var/www/ghost/system/files/ghost_localhost.service /lib/systemd/system/ghost_localhost.service
Running sudo command: systemctl daemon-reload
? Do you wish to set up Systemd? Yes
✔ Creating systemd service file at /var/www/ghost/system/files/ghost_localhost.service
Running sudo command: ln -sf /var/www/ghost/system/files/ghost_localhost.service /lib/systemd/system/ghost_localhost.service
Running sudo command: systemctl daemon-reload
✔ Setting up Systemd
Running sudo command: -E -u ghost /usr/lib/node_modules/ghost-cli/node_modules/.bin/knex-migrator-migrate --init --mgpath /var/www/ghost/current
✖ Running database migrations
An error occurred.
Message: 'Command failed: /bin/sh -c sudo -E -u ghost /usr/lib/node_modules/ghost-cli/node_modules/.bin/knex-migrator-migrate --init --mgpath /var/www/ghost/current
[2017-07-31 09:21:30] ERROR

NAME: InternalServerError
CODE: ECONNREFUSED
MESSAGE: The server has encountered an error.

level:normal

InternalServerError: The server has encountered an error.
at new KnexMigrateError (/usr/lib/node_modules/ghost-cli/node_modules/knex-migrator/lib/errors.js:7:26)
at /usr/lib/node_modules/ghost-cli/node_modules/knex-migrator/lib/database.js:58:19
at tryCatcher (/usr/lib/node_modules/ghost-cli/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/usr/lib/node_modules/ghost-cli/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/usr/lib/node_modules/ghost-cli/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/usr/lib/node_modules/ghost-cli/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/usr/lib/node_modules/ghost-cli/node_modules/bluebird/js/release/promise.js:689:18)
at Async._drainQueue (/usr/lib/node_modules/ghost-cli/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/usr/lib/node_modules/ghost-cli/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/usr/lib/node_modules/ghost-cli/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)

Error: connect ECONNREFUSED 127.0.0.1:3306
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)
--------------------
at Protocol._enqueue (/usr/lib/node_modules/ghost-cli/node_modules/mysql/lib/protocol/Protocol.js:141:48)
at Protocol.handshake (/usr/lib/node_modules/ghost-cli/node_modules/mysql/lib/protocol/Protocol.js:52:41)
at Connection.connect (/usr/lib/node_modules/ghost-cli/node_modules/mysql/lib/Connection.js:130:18)
at /usr/lib/node_modules/ghost-cli/node_modules/knex/lib/dialects/mysql/index.js:106:18
at Promise._execute (/usr/lib/node_modules/ghost-cli/node_modules/bluebird/js/release/debuggability.js:300:9)
at Promise._resolveFromExecutor (/usr/lib/node_modules/ghost-cli/node_modules/bluebird/js/release/promise.js:483:18)
at new Promise (/usr/lib/node_modules/ghost-cli/node_modules/bluebird/js/release/promise.js:79:10)
at Client_MySQL.acquireRawConnection (/usr/lib/node_modules/ghost-cli/node_modules/knex/lib/dialects/mysql/index.js:104:12)
at Object.create (/usr/lib/node_modules/ghost-cli/node_modules/knex/lib/client.js:239:16)
at Pool._createResource (/usr/lib/node_modules/ghost-cli/node_modules/generic-pool/lib/generic-pool.js:354:17)
at Pool._ensureMinimum (/usr/lib/node_modules/ghost-cli/node_modules/generic-pool/lib/generic-pool.js:408:12)
at new Pool (/usr/lib/node_modules/ghost-cli/node_modules/generic-pool/lib/generic-pool.js:157:8)
at Client_MySQL.initializePool (/usr/lib/node_modules/ghost-cli/node_modules/knex/lib/client.js:269:17)
at Client_MySQL.Client (/usr/lib/node_modules/ghost-cli/node_modules/knex/lib/client.js:116:12)
at new Client_MySQL (/usr/lib/node_modules/ghost-cli/node_modules/knex/lib/dialects/mysql/index.js:62:20)
at Knex (/usr/lib/node_modules/ghost-cli/node_modules/knex/lib/index.js:60:34)
at Object.connect (/usr/lib/node_modules/ghost-cli/node_modules/knex-migrator/lib/database.js:24:12)
at Object.createDatabaseIfNotExist (/usr/lib/node_modules/ghost-cli/node_modules/knex-migrator/lib/database.js:41:30)
at KnexMigrator.init (/usr/lib/node_modules/ghost-cli/node_modules/knex-migrator/lib/index.js:71:21)
at KnexMigrator.migrate (/usr/lib/node_modules/ghost-cli/node_modules/knex-migrator/lib/index.js:158:21)
at /usr/lib/node_modules/ghost-cli/node_modules/knex-migrator/bin/knex-migrator-migrate:26:29
at tryCatcher (/usr/lib/node_modules/ghost-cli/node_modules/bluebird/js/release/util.js:16:23)

'

Debug Information:
Node Version: v6.11.1
Ghost-CLI Version: 1.0.1
Environment: production
Command: 'ghost setup'

Additional log info available in: /home/recon/.ghost/logs/ghost-cli-debug-2017-07-31T09_21_30_330Z.log

Please refer to https://docs.ghost.org/docs/installing-ghost-via-the-cli#troubleshooting for troubleshooting.


Please help me out, thanks anyway!

@ErisDS

This comment has been minimized.

Member

ErisDS commented Jul 31, 2017

It is not the systemd step that is failing, but this one:

Running database migrations

ECONNREFUSED to port 3306 is referring to your MySQL service.

Do you have a running MySQL service, and are the credentials you provided valid?

@vistaing

This comment has been minimized.

vistaing commented Jul 31, 2017

Sorry about my lack of related knowledge. I've updated the log, and it includes all after 'ghost install'.

The only command about MySQL I typed was 'sudo apt-get install mysql-server' when installing it. What should I do now?

@vistaing

This comment has been minimized.

vistaing commented Jul 31, 2017

I tried this:

telnet localhost 3306

and it says:

Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused

@ErisDS

This comment has been minimized.

Member

ErisDS commented Jul 31, 2017

Hi @vistaing I was pointing out that the X (failed task) was next to the mysql task, and not the systemd task (that has a tick next to it, so succeeded).

Knowing that an ECONNRESET with port 3306 means MySQL is definitely something that Ghost CLI could handle and tell you explicitly - we can look at adding some clearer error messages here.

It seems the documentation for setting up mysql in the migration guide is not complete. Sorry about that. For now I recommend following this guide: https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-16-04. CC @sebgie can you please take a second look at the setup docs when you have a minute? According to digital ocean the security task is needed & also the service needs to be explicitly started.

@vistaing

This comment has been minimized.

vistaing commented Jul 31, 2017

@ErisDS Thank you for you replies!

Seems that sudo apt-get install mysql-server is not enough. I should install some core object (like mysql-client-core-xxx) first according to my attempts just now.

@vistaing

This comment has been minimized.

vistaing commented Jul 31, 2017

@ErisDS I solved it (although I didn't fully understand the mechanics)!

It seems that users should be informed that running sudo apt-get install mysql-server on a blank server is not enough for getting things done.

Thank you for your generous guide on this simple issue !!

@sebgie

This comment has been minimized.

Contributor

sebgie commented Jul 31, 2017

@vistaing to get a better understanding of how this occured could you please describe what steps you took to get to that stage?

  • You had an installation on 0.11.11? What Ubuntu version was this running on?
  • Did you try the migration on the existing server or started a new droplet before migrating?
  • What did you do in between? Export/Import?
  • What's the Ubuntu version of the new droplet?
  • How did you you get your issue resolved? Was it missing other packages (mysql-client-core-xxx) or something else?
@vistaing

This comment has been minimized.

vistaing commented Jul 31, 2017

@sebgie Glad to share more detail with you:

  • My current blog is 0.11.11- running on droplet A. In case of wrong moves, I started a brand new droplet B on DigitalOcean. Both droplets are running Ubuntu 16.04 x64.
  • My plan is setting up B first, then migrate stuff on A to B under the guide of the official tutorial mentioned above.
  • All I did so far is setting up B. No data transmission move between these two droplets.
  • I try to test whether MySQL is running correctly so I typed 'mysql'. The result contains name of mysql-client-core and mariadb-client-core, so I installed them via apt-get.
  • After the installation of these two on B, 'ghost setup' finally works to the end. So I guess mysql-server alone might result in problems I met just now.

Thanks for reading! Maybe it's hard for a veteran to commit the same move, but as a newbie in development, I really didn't know that I should manually install mysql-client first.

@ErisDS ErisDS changed the title from Can't get through systemd setting while installing Ghost via CLI to Can't get through mysql setting while installing Ghost via CLI Jul 31, 2017

@sebgie

This comment has been minimized.

Contributor

sebgie commented Jul 31, 2017

So, I have tried this out on a new droplet on DO. I can reproduce the output mentioned above if mysql-server installation fails. This could happen if the package list in apt is not updated (sudo apt-get update) before installing mysql-server.

The output after that looks like this:

$mysql
The program 'mysql' can be found in the following packages:
 * mysql-client-core-5.7
 * mariadb-client-core-10.0

I have added a new section about updating the package list and upgrading installed packages to the documentation.

@acburdine acburdine self-assigned this Jul 31, 2017

@acburdine acburdine added bug UI labels Jul 31, 2017

@acburdine

This comment has been minimized.

Member

acburdine commented Aug 1, 2017

Leaving this issue open so I can add an additional check to the migrate step to handle ECONNREFUSED errors with a better error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment