mysql connection string
Generate MySQL connection strings for common apps, drivers, and CLI tools
Build MySQL connection strings for URI, JDBC, SQLAlchemy, PDO, and the mysql command line, then copy the format you need.
Edit the fields once and every output format updates instantly.
Connection details
Output options
Generated formats
Pick the format that matches your app or driver.
MySQL URI
Useful for many app configs and environment variables.
mysql://root:secret@127.0.0.1:3306/app_db?charset=utf8mb4JDBC
Common in Java and Spring-based applications.
jdbc:mysql://127.0.0.1:3306/app_db?user=root&password=secret&useSSL=false&characterEncoding=utf8mb4SQLAlchemy
Typical format for Python apps using SQLAlchemy and PyMySQL.
mysql+pymysql://root:secret@127.0.0.1:3306/app_db?charset=utf8mb4PHP PDO
DSN format for PHP applications using PDO.
mysql:host=127.0.0.1;port=3306;dbname=app_db;charset=utf8mb4mysql CLI
Paste into Terminal for quick connection testing.
mysql -h 127.0.0.1 -P 3306 -u root -p app_dbKeep database access close to the rest of your remote workflow
After you generate the connection string, DartShell can help you keep SSH, file transfer, and database access in one Mac workspace.
What this MySQL connection string generator helps with
App environment variables
Generate a MySQL URI when a framework asks for a single DATABASE_URL style string.
JDBC and backend setup
Use the JDBC format for Java projects, or copy the SQLAlchemy format for Python backends.
Quick connection checks
Use the mysql CLI output to test credentials and connectivity before wiring the database into your app.
Common examples
App config
mysql://app_user:secret@db.example.com:3306/app_db?charset=utf8mb4JDBC
jdbc:mysql://db.example.com:3306/app_db?user=app_user&password=secret&useSSL=true&characterEncoding=utf8mb4CLI
mysql -h db.example.com -P 3306 -u app_user -p app_dbSQLAlchemy / PyMySQL
mysql+pymysql://app_user:secret@db.example.com:3306/app_db?charset=utf8mb4PDO (PHP)
mysql:host=db.example.com;port=3306;dbname=app_db;charset=utf8mb4Common MySQL connection errors
These messages cover the cases that take the longest to diagnose: a blocked port, an account bound to the wrong host, and driver options that disagree with the server.
| Error message | What it means | What to change |
|---|---|---|
| ERROR 2003 (HY000): Can't connect to MySQL server on 'host' | The port is unreachable, bind-address limits the server to 127.0.0.1, or a firewall and security group block it. | Run nc -vz db.example.com 3306 from your Mac, then check bind-address in my.cnf and the cloud security group. |
| ERROR 1045 (28000): Access denied for user 'app_user'@'host' | The password is wrong, or the account is granted only from a different host such as localhost. | Verify with mysql -h db.example.com -P 3306 -u app_user -p, then check the grant with SHOW GRANTS FOR 'app_user'@'%'; |
| ERROR 1049 (42000): Unknown database 'app_db' | The database name is misspelled or has not been created yet. | Connect without a database and run SHOW DATABASES; then correct the final segment of the connection string. |
| Public Key Retrieval is not allowed | MySQL 8 uses caching_sha2_password, and the JDBC driver refuses to fetch a public key over an unencrypted connection. | Add allowPublicKeyRetrieval=true&useSSL=true to the JDBC URL. In production, configure TLS rather than disabling the check. |
| The server time zone value 'XXX' is unrecognized | The JDBC driver cannot resolve the server's time zone. | Add serverTimezone=UTC (or Asia/Shanghai) to the JDBC URL, or load the time zone tables on the server. |
| Connections using insecure transport are prohibited | The client asks for a plain connection while the server has require_secure_transport enabled. | Switch to sslMode=REQUIRED with a CA certificate, or ask the administrator to change the server policy. |
Related tools
PostgreSQL connection string generator
Generate URI, JDBC, libpq, SQLAlchemy, and psql formats for PostgreSQL.
Redis connection string generator
Build redis:// and rediss:// URLs when the app also needs a cache or queue.
SSH port forwarding generator
Reach a database that only listens on a private network through an SSH tunnel.