1

我正在学习 Gitpod 并面临一个问题;我通过 docker-compose 启动了 mysql 服务器,并尝试通过 nodejs 脚本获取数据,它在本地工作,但在 Gitpod 上不起作用。你能告诉我是什么原因吗?

我写的代码在这篇文章的底部。它描述了我在本地得到的期望结果,但我在 Gitpod 上得到的结果就在这里;

gitpod /workspace/gitpod-mysql2 $ yarn
yarn install v1.22.10
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...

Done in 0.75s.
gitpod /workspace/gitpod-mysql2 $ docker-compose up -d
Creating network "gitpod-mysql2_default" with the default driver
Creating volume "gitpod-mysql2_mysql" with default driver
Pulling mysql (mysql:5.7)...
5.7: Pulling from library/mysql
33847f680f63: Pull complete
5cb67864e624: Pull complete
1a2b594783f5: Pull complete
b30e406dd925: Pull complete
48901e306e4c: Pull complete
603d2b7147fd: Extracting  3.113MB/13.45MB
802aa684c1c4: Download complete
603d2b7147fd: Pull complete
802aa684c1c4: Pull complete
5b5a19178915: Pull complete
f9ce7411c6e4: Pull complete
f51f6977d9b2: Pull complete
aeb6b16ce012: Pull complete
Digest: sha256:be70d18aedc37927293e7947c8de41ae6490ecd4c79df1db40d1b5b5af7d9596
Status: Downloaded newer image for mysql:5.7
Creating mysql ... done
gitpod /workspace/gitpod-mysql2 $ node main.js
undefined
undefined
events.js:352
      throw er; // Unhandled 'error' event
      ^

Error: Connection lost: The server closed the connection.
    at Socket.<anonymous> (/workspace/gitpod-mysql2/node_modules/mysql2/lib/connection.js:101:31)
    at Socket.emit (events.js:375:28)
    at TCP.<anonymous> (net.js:675:12)
Emitted 'error' event on Connection instance at:
    at Connection._notifyError (/workspace/gitpod-mysql2/node_modules/mysql2/lib/connection.js:236:12)
    at Socket.<anonymous> (/workspace/gitpod-mysql2/node_modules/mysql2/lib/connection.js:107:12)
    at Socket.emit (events.js:375:28)
    at TCP.<anonymous> (net.js:675:12) {
  fatal: true,
  code: 'PROTOCOL_CONNECTION_LOST'
}
gitpod /workspace/gitpod-mysql2 $ 

https://github.com/takuyahara/gitpod-mysql2

4

0 回答 0