MySQL Connection String Generator

Generate connection strings for MySQL in any format. JDBC, .NET, Python, Node.js, Go, PHP, and more.

Client-side only — nothing leaves your browser

mysql://root:@localhost:3306/mydb?ssl-mode=DISABLED&charset=utf8mb4

What is a MySQL Connection String?

A MySQL connection string contains all the information needed to connect to a MySQL database: host address, port, database name, credentials, SSL settings, and character set. Different programming languages and drivers use different formats — from URI-style strings to key-value pairs and Go's unique DSN format.

SSL Mode Options

  • disabled — No SSL (not recommended for production)
  • required — Use SSL, don't verify certificate
  • verify_ca — Verify the server certificate is signed by a trusted CA
  • verify_identity — Verify certificate and hostname match

Quick Reference

FormatExample Pattern
MySQL URImysql://user:pass@host:3306/db?ssl-mode=REQUIRED
JDBC (Java)jdbc:mysql://host:3306/db?user=user&password=pass&sslMode=REQUIRED
.NET (MySqlConnector)Server=host;Port=3306;Database=db;User Id=user;Password=pass
Node.js (mysql2)mysql://user:pass@host:3306/db
Python (mysqlclient)mysql://user:pass@host:3306/db
Go (go-sql-driver)user:pass@tcp(host:3306)/db?tls=true&charset=utf8mb4
PHP (PDO)mysql:host=host;port=3306;dbname=db;charset=utf8mb4
Ruby (mysql2)mysql2://user:pass@host:3306/db

Frequently Asked Questions

What is a MySQL connection string?
A MySQL connection string is a formatted text string that contains all the parameters needed to establish a connection to a MySQL database — including the host address, port, database name, username, password, and options like SSL mode and character set. The exact format varies by programming language and driver (e.g., URI style for Node.js, DSN style for Go, key-value for .NET).
What is the difference between a MySQL connection string and a MySQL connector?
A connection string is the configuration text that tells your application how to reach the database (host, port, credentials, etc.). A MySQL connector is the driver or library that reads that connection string and actually establishes the connection — for example, mysql2 for Node.js, mysqlclient for Python, or MySqlConnector for .NET. You need both: the connector (installed as a dependency) and the connection string (passed to it at runtime).
How do I handle special characters in a MySQL connection string password?
For URI-style connection strings (mysql://...), special characters like @, #, :, /, and spaces must be URL-encoded — for example, @ becomes %40 and # becomes %23. Key-value formats like .NET and PHP PDO do not require encoding. Go's DSN format also does not URL-encode passwords. Our generator handles this automatically based on the selected format.
How do I connect to MySQL in Docker?
When connecting from another container in the same Docker network, use the container or service name as the host (e.g., mysql://root:pass@mysql-container:3306/db). From the host machine, use 'localhost' with the mapped port. In Docker Compose, use the service name defined in your docker-compose.yml as the hostname. Make sure the MySQL container has finished initializing before connecting.
How do I find my MySQL connection string in phpMyAdmin?
phpMyAdmin does not display a ready-made connection string, but you can find the individual values. Go to the home page and check the 'Database server' section for the host and port. Your username is shown in the top navigation bar. Combine these with your password and database name to build a connection string using this generator. For cloud-hosted MySQL (AWS RDS, PlanetScale, etc.), check your provider's dashboard for a pre-built connection string.
MySQL

Need a MySQL GUI Client?

1bench is a modern database client for MySQL and 20+ other databases. Query, browse, and manage your data visually.

Learn More