MySQL Driver keeps asking for 'password' parameter

When trying to connect to my local MySQL database, to which I do not have any password setup, I get an error when running drizzle-kit migrate command. Here's my drizzle.config.ts file, I double checked the docs but I can't seem to figure out what I'm missing out:
import { defineConfig } from "drizzle-kit";

if (!process.env.DB_NAME) {
throw new Error("ERROR: 'DB_NAME' env is not setup correctly!");
}

if (!process.env.DB_HOST) {
throw new Error("ERROR: 'DB_HOST' env is not setup correctly!");
}

export default defineConfig({
schema: "./src/db/schema/*",
dialect: "mysql",
out: "./src/db/migrations",
migrations: {
prefix: "timestamp",
},
dbCredentials: {
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
},
strict: true,
verbose: true,
});
import { defineConfig } from "drizzle-kit";

if (!process.env.DB_NAME) {
throw new Error("ERROR: 'DB_NAME' env is not setup correctly!");
}

if (!process.env.DB_HOST) {
throw new Error("ERROR: 'DB_HOST' env is not setup correctly!");
}

export default defineConfig({
schema: "./src/db/schema/*",
dialect: "mysql",
out: "./src/db/migrations",
migrations: {
prefix: "timestamp",
},
dbCredentials: {
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
},
strict: true,
verbose: true,
});
In my .env file I have the fields setup, and the DB_PASSWORD variable has an empty string value as there's no password associated with the database user. The error that I get is Please provide required params for MySQL driver: and the password field is marked with an X and an empty string value.
1 Reply
pecko0326
pecko03263mo ago
As it was mentioned in another post, setting a password for your local MySQL root user and reading that password in the configuration file, seems to be working fine. This is some edge case I guess.
Want results from more Discord servers?
Add your server