0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

prismaで微妙につまずいた話

Last updated at Posted at 2024-07-23

概要

next.jsで prismaとローカルのMySQLで環境構築しようとしたときに、

$ mysql -u root -p
  Enter password: 
  ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using 
  password: YES)

パスワードは絶対にあっているのに接続ができませんでした。

割と意外な理由だったのでメモとして書いておきます。

ネタバレするとパスワードに # を含んでいると上手くいかないようです。
微妙!

環境

OS : Fedora 39
prisma: v5.17.0
MySQL : v8.4.1

解決方法

パスワードを変更したら接続できるようになりました。

例:

#password -> password+
# .env
DATABASE_URL="mysql://root:password+@localhost:3306/database_name"
$ npx prisma migrate dev --name init
  Environment variables loaded from .env
  Prisma schema loaded from prisma/schema.prisma
  Datasource "db": MySQL database "database_name" at "localhost:3306"

  Applying migration `20240723142312_init`

  The following migration(s) have been created and applied from new 
  schema changes:

  migrations/
    └─ 20240723142312_init/
      └─ migration.sql

  Your database is now in sync with your schema.

  ✔ Generated Prisma Client (v5.17.0) to ./node_modules/@prisma/client 
  in 88ms
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?