Either "uri" or "host", "database" are required for database connection

46 Views Asked by At

I'm trying to learn Drizzle and I've got a problem when I tried to push my schema to my database. I'm only using SQL workbench.

This is my Workbench settings.

enter image description here password: admin

I tried npm run db:generate and it creates a database. enter image description here

But when I tried to run npm run db:push I get this error

Either "uri" or "host", "database" are required for database connection

This is my drizzle.config.ts

import type { Config } from "drizzle-kit";
import dotenv from "dotenv";

dotenv.config();

export default {
  schema: "./src/db/schema.ts",
  out: "./src/db/migrations",
  dbCredentials: {
    connectionString: process.env.DB_URL!,
 
 },
  driver: "mysql2",
} satisfies Config;`

And this is my .env

DB_URL="mysql:admin@admin:3306/drizzlenode"
1

There are 1 best solutions below

0
Stykgwar On

NVM, I just saw it,

import type { Config } from "drizzle-kit";
import dotenv from "dotenv";

dotenv.config();

export default {
  schema: "./src/db/schema.ts",
  out: "./src/db/migrations",
  dbCredentials: {
    host: "localhost",
    port: 3306,
    user: "admin",
    password: "admin",
    database: "drizzlenode",
  },
  driver: "mysql2",
} satisfies Config;