System Information
- Strapi Version: 3.1.6:
- Operating System: Manjaro:
- Database: MySQL:
- Node Version: 12.20.2:
- NPM Version: 6.14.11:
- Yarn Version: 1.22.10:
I tried to connect Strapi to hosted MySQL but did not work.
When using strapi with local MySQL database at localhost, the connection was success and the development mode was working. But when I tried to connect Strapi with hosted MySQL database at different host I got an error
[2021-03-26T00:47:34.121Z] debug ⛔️ Server wasn't able to start properly.
[2021-03-26T00:47:34.123Z] error Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:209:20)
at Protocol._enqueue (/home/arkjuniork/Dev/history-department/backend/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/home/arkjuniork/Dev/history-department/backend/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/home/arkjuniork/Dev/history-department/backend/node_modules/mysql/lib/Connection.js:116:18)
at /home/arkjuniork/Dev/history-department/backend/node_modules/knex/lib/dialects/mysql/index.js:68:18
From previous event:
at Client_MySQL.acquireRawConnection (/home/arkjuniork/Dev/history-department/backend/node_modules/knex/lib/dialects/mysql/index.js:63:12)
at create (/home/arkjuniork/Dev/history-department/backend/node_modules/knex/lib/client.js:258:21)
at /home/arkjuniork/Dev/history-department/backend/node_modules/tarn/lib/Pool.js:389:34
at Object.tryPromise (/home/arkjuniork/Dev/history-department/backend/node_modules/tarn/lib/utils.js:53:24)
at /home/arkjuniork/Dev/history-department/backend/node_modules/tarn/lib/Pool.js:389:17
at new Promise (<anonymous>)
at callbackOrPromise (/home/arkjuniork/Dev/history-department/backend/node_modules/tarn/lib/Pool.js:380:12)
at Pool._create (/home/arkjuniork/Dev/history-department/backend/node_modules/tarn/lib/Pool.js:290:9)
at Pool._doCreate (/home/arkjuniork/Dev/history-department/backend/node_modules/tarn/lib/Pool.js:260:36)
at Pool._tryAcquireOrCreate (/home/arkjuniork/Dev/history-department/backend/node_modules/tarn/lib/Pool.js:211:18)
at Pool.acquire (/home/arkjuniork/Dev/history-department/backend/node_modules/tarn/lib/Pool.js:117:14)
at /home/arkjuniork/Dev/history-department/backend/node_modules/knex/lib/client.js:312:43
From previous event:
at Client_MySQL.acquireConnection (/home/arkjuniork/Dev/history-department/backend/node_modules/knex/lib/client.js:312:26)
at Runner.ensureConnection (/home/arkjuniork/Dev/history-department/backend/node_modules/knex/lib/runner.js:246:8)
at Runner.run (/home/arkjuniork/Dev/history-department/backend/node_modules/knex/lib/runner.js:25:27)
at SchemaBuilder.Target.then (/home/arkjuniork/Dev/history-department/backend/node_modules/knex/lib/interface.js:14:43)
error Command failed with exit code 1.
Here is my database.js configuration
module.exports = ({ env }) => ({
defaultConnection: "default",
connections: {
default: {
connector: "bookshelf",
settings: {
client: "mysql",
host: env("DATABASE_HOST", "103.195.142.197"),
port: env.int("DATABASE_PORT", 3306),
database: env("DATABASE_NAME", "dbsejarah01"),
username: env("DATABASE_USERNAME", "username"),
password: env("DATABASE_PASSWORD", "password"),
},
options: {},
},
},
});
Was Strapi not supported to connect with database at different host?
Your help means a lot for me. Thank you.