mysql - 如何将快递服务器与aws实例中的数据库连接起来
问题描述
我正在使用 express 和 typescript 制作服务器,但我无法将服务器连接到我在 aws 实例中拥有的数据库,这是服务器代码:
import { createPool } from 'mysql2';
export async function conectar() {
const conectando = await createPool({
host:'myIPInstance',
port: 3306,
user:'myuser',
password:'mypass',
database:'example',
connectionLimit: 10
});
return conectando;
}
当我查看表格的内容时,我收到以下错误:
(node:4704) [DEP0018] DeprecationWarning: Unhandled promise rejections
are deprecated. In the future, promise rejections that are not handled
will terminate the Node.js process with a non-zero exit code.
[1] events.js:177
[1] throw er; // Unhandled 'error' event
[1] ^
[1]
[1] Error: getaddrinfo ENOTFOUND https://3.13.108.243
[1] at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26)
[1] Emitted 'error' event at:
[1] at /home/node_modules/mysql2/lib/pool.js:143:20
[1] at /home/node_modules/mysql2/lib/pool.js:59: 18
[1] at PoolConnection.<anonymous (/home/node_modules/mysql2/lib/connection.js:716:13)
[1] at Object.onceWrapper (events.js:288:20)
[1] at PoolConnection.emit (events.js:205:15)
[1] at PoolConnection._notifyError (/home/node_modules/mysql2/lib/connection.js:212:12)
[1] at PoolConnection._handleFatalError (/home/node_modules/mysql2/lib/connection.js:151:10)
[1] at PoolConnection._handleNetworkError (/home/node_modules/mysql2/lib/connection.js:160:10)
[1] at Socket.emit (events.js:200:13)
[1] at emitErrorNT (internal/streams/destroy.js:91:8) {
[1] errno: 'ENOTFOUND',
[1] code: 'ENOTFOUND',
[1] syscall: 'getaddrinfo',
[1] hostname: 'MyIpInstance',
[1] fatal: true
[1] }
我该如何解决这个错误,我需要什么?
解决方案
推荐阅读
- java - Spring AOP 看不到方法
- react-native - React Native 显示动画 SVG
- nestjs - Nest 无法解析 BookingService 的依赖关系
- algorithm - 按包含进行文件聚类 - 聚类有向图问题
- image - 如何在处理中制作清晰的像素艺术图像?
- python - 从 Python 中的数组结构中的二进制文件中读取二进制数据段
- python - gunicorn 在运行 apache 气流网络服务器时出错
- sql - 这个 SQL 查询中的“i”代表什么?
- html - 使用电子邮件 HTML 防弹背景图片,但得到一个奇怪的空框
- mapbox - 我可以限制每个 Mapbox API 密钥的计费周期的负载吗