Prisma URL string for MySQL connection via sockets

438 Views Asked by At

According to Prisma docs the template for the connection string using sockets is:

mysql://USER:POST@localhost/database?socket=/var/run/mysql/

Based on this I've created the following, changing the USER to root, database to my issue_tracker database and the location of the socket query string for my Ubuntu 22.04 installation which is /var/run/mysqld/ so my string is:

mysql://root:POST@localhost/issue_tracker?socket=/var/run/mysqld/

What I'm unsure of is what I'm supposed to replace POST with. If I leave it as the above and try to run a migration I get the following error:

Error: P1001: Can't reach database server at `localhost`:`3306`

Please make sure your database server is running at `localhost`:`3306`.

What is POST field after user field in the Prisma example template supposed to represent?

1

There are 1 best solutions below

0
On

I gave up on using the default mysql socket connection method that was configured automatically during the Ubuntu installation instructions and used the following command to change the mysql authentication plugin from auth_socket to caching_sha2_password. This is done using the following from the mysql command-line:

ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'new-password-here';

I could then simply refer to Prisma docs to use the connection string pattern discussed under Base URL and path, specifically the string pattern:

mysql://USER:PASSWORD@HOST:PORT/DATABASE

Prisma migrations now work.

FYI. This is for MySQL version 8.0.35