Connection strings for your app
A connection string tells your app where its database is and how to sign in. The panel writes one for each common language, filled in with your database's real name, user and host. You add the password.
Copy a connection string
- Open Account → Hosting → your site → Databases.
- Click Manage beside the database.
- Under Connection strings, choose where the app runs:
- From your sites for code on this hosting account. The host is
localhost. - From another computer for a laptop, another server or a cloud service. The host is your remote database host, with encryption on.
- From your sites for code on this hosting account. The host is
- Choose the language tab, such as WordPress (wp-config.php) or Laravel (.env).
- If the database has more than one user, pick the User.
- Click Copy and paste it into your app's settings.
- Replace
YOUR_PASSWORDwith that user's password.
Why the password isn't filled in
We never show a database password after it's set, and the page never contains one. If you've lost it, set a new one with Change password in Users and access on the Databases page, then update every app that uses that user.
Keep passwords out of code you share. In Node.js and Laravel, read it from an environment variable instead. See Environment variables.
Examples from your sites
For a database example_shop with user example_shop:
// PHP (PDO)
$pdo = new PDO(
'mysql:host=localhost;port=3306;dbname=example_shop;charset=utf8mb4',
'example_shop',
'YOUR_PASSWORD',
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
);
// wp-config.php
define( 'DB_NAME', 'example_shop' );
define( 'DB_USER', 'example_shop' );
define( 'DB_PASSWORD', 'YOUR_PASSWORD' );
define( 'DB_HOST', 'localhost' );
# Laravel .env
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=example_shop
DB_USERNAME=example_shop
DB_PASSWORD=YOUR_PASSWORD
// Node.js (mysql2)
const mysql = require('mysql2/promise');
async function connect() {
return mysql.createConnection({
host: 'localhost',
user: 'example_shop',
password: process.env.DB_PASSWORD,
database: 'example_shop',
});
}
# Python (SQLAlchemy with PyMySQL)
from sqlalchemy import create_engine
engine = create_engine(
"mysql+pymysql://example_shop:YOUR_PASSWORD@localhost:3306/example_shop?charset=utf8mb4",
pool_pre_ping=True,
)
From another computer
Remote strings add encryption, and switch off the certificate name check. The server's certificate names the machine your database runs on rather than your domain, so a strict name check fails even though the connection is encrypted. Connect to MySQL remotely explains this choice, and how to use an SSH tunnel if you need full certificate checking.
Before a remote string works, add your computer's IP address under Remote access on the Databases page.
Laravel reads TLS settings from config/database.php, not .env. Under connections.mysql, set:
'options' => [
PDO::MYSQL_ATTR_SSL_CA => '',
PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false,
],
If From another computer shows no strings, your plan has no remote database host yet. Connect through an SSH tunnel instead, as Connect to MySQL remotely shows, then use the strings under From your sites.
If something goes wrong
| Error | Fix |
|---|---|
Access denied for user |
Wrong password, or the user has no access to this database. Check Users and access |
Unknown database |
The name is missing the account prefix. Copy it again from the panel |
Can't connect from another computer |
Your IP isn't under Remote access, or the app is using localhost |
| A WordPress error page | See Fix "Error establishing a database connection" |
Still stuck? Ask us and we'll walk you through it.
