TypeORM数据源显示客户端密码错误



我有以下数据源。ts文件:

import {DataSource} from "typeorm";
import path from "path";
import {User} from "./entity/User";
import { config } from "dotenv";
config();
export const AppDataSource = new DataSource({
type: "postgres",
host: process.env.DATABASE_HOST,
port: parseInt(process.env.DATABASE_PORT),
username: process.env.DATABASE_USERNAME,
password: process.env.DATABASE_PASSWORD,
logging: true,
entities: [
User,
],
migrations: [
path.join(__dirname, "./migration/*"),
],
});

当我尝试用yarn typeorm-ts-node-esm -d ./dist/data-source.js migration:generate ./src/migration/init出现如下错误:SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string

有什么建议吗?

尝试不同的类型配置,没有成功

这是一个数据库设置错误,上面的代码是100%正确的

import { Global, Module } from "@nestjs/common";
import { ConfigModule, ConfigService } from "@nestjs/config";
import { TypeOrmModule } from "@nestjs/typeorm";
@Global()
@Module({
imports: [
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
useFactory: (configService: ConfigService) => ({
type: "mssql",
host: configService.get<string>("DATABASE_HOST"),
port: +configService.get<number>("DATABASE_PORT"),
username: configService.get<string>("DATABASE_USER"),
password: configService.get<string>("DATABASE_PASSWORD"),
database: configService.get<string>("DATABASE_DB"),
schema: configService.get<string>("DATABASE_SCHEMA"),
requestTimeout: 6000,
extra: {
trustServerCertificate: true,
},
options: {
encrypt: false,
},
synchronize: true,
logging: true,
autoLoadEntities: true,
entities: [
UserEntity,
AddressEntity,
DivisionEntity,
],
}),
inject: [ConfigService],
})
],
})
export class TypeormConfigModule {}

This may help…

相关内容

  • 没有找到相关文章

最新更新