Skip to content

Error parsing MySQL URLs #3921

@jrwaine

Description

@jrwaine

Bug description

The program does not parse correctly MySQL URL's when reserved characters are used (in password, for example).

When using a URL such as mysql://root:password_with_#@localhost:3306/mydb it outputs.

Introspecting based on datasource defined in prisma/schema.prisma …
Error: Error parsing connection string: invalid port number in `mysql://root:password_with_#@localhost:3306/mydb`)

How to reproduce

  1. Create a user with a password with MySQL reserved characters (I only tested with #).
  2. Run npx prisma introspect with a database URL for this user.

It should output something as

Introspecting based on datasource defined in prisma/schema.prisma …
Error: Error parsing connection string: invalid port number in `mysql://root:password-with-#@localhost:3306/mydb`)

I tried escaping the character with %, as specified by MySQL, and using quotation marks, but the error continued.

Expected behavior

The URL should be parsed correctly and the command run with success.

Prisma information

File schema.prisma

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

Environment & setup

  • OS: Fedora 32
  • Database: MySQL
  • Node.js version: v12.18.3
  • Prisma version: 2.8.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/0-unknownBug is new, does not have information for reproduction or reproduction could not be confirmed.kind/bugA reported bug.topic: connection-url

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions