I'm writing my first project with Nestjs and I'm having trouble connecting to the database. I installed mysql and set up the connection. TypeOrm creates the database itself? or do i have to do it with mysql?
Nest] 13684 - 07/24/2020, 12:44:50 AM [TypeOrmModule] Unable to connect to the database. Retrying (1)... +42ms
Error: ER_BAD_DB_ERROR: Unknown database 'my-database'
app.module.ts
@Module({
imports: [
TypeOrmModule.forRoot({
type: 'mysql',
host: 'localhost',
username: 'root',
password: 'password',
database: 'my-database',
entities: [User],
synchronize: true,
}),
],
controllers: [AppController],
providers: [AppService],
})
First you should create the my-database database in your mysql server.
The TypeOrmModule create only tables (in in first time.)
CREATE DATABASE myDatabase; (I recommend, use this format: myDatabase.)That's it!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With