Node 18.16.0
Nestjs 10.0.0
TypeScript 5.1.3
MySQL 8.0.33
Prisma 4.16.2
table_nameは、設定したいDBの名前を指定
$ mysql -u root -p
> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
> CREATE DATABASE table_name;
$ touch .env
上記画像を参考にDATABASE_URL
の値に設定
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
例)
DATABASE_URL="mysql://root:[email protected]:3306/nest_template"
$ npm install
$ npm run start:dev