Just going through Mosh’s Next.JS Issue Tracker course and having utter frustration with the DATABASE_URL
string for Prisma to use in .env
file.
I installed MySQL on my Ubuntu WSL installation on Windows and also ran the mysql_secure_installation
. Oddly, I was not asked to provide a password and the sudo apt install mysql-server
method of installing has defaulted to using auth-socket
instead of a password, so in this case Prisma says the connection string if using sockets and not password should look like this:
mysql://USER:POST@localhost/database?socket=/var/run/mysql/
I change USER to root
, database to issue_tracker
and the socket path to /var/run/mysqld/
which is the path as set in my Ubuntu install.
This results in:
mysql://root:POST@localhost/issue_tracker?socket=/var/run/mysqld/
Running a migration with this results in the following error:
Error: P1001: Can't reach database server at `localhost`:`3306`
Please make sure your database server is running at `localhost`:`3306`.
The annoying thing is I can easily connect to mysql
from the terminal command line using sudo mysql
and check the status and default users and databases in there. I just cannot get the Prisma connection string to work.
I suspect it has to be something to do with the word POST, as shown in the Prisma docs example. What the hell are you supposed to replace that with? Or do you leave it as POST
At this stage I might just drop MySQL and use PostgresSQL which I’ve never had issues connecting with before (though not from Prisma).
Any advice will be appreciated.