--- title: "Connect to Miget Databases" description: "Connect to Miget-managed databases from outside the platform." --- This guide shows how to connect to Miget-managed databases from machines outside Miget. The method depends on the database type: - **PostgreSQL** - Use the built-in public endpoint (no additional setup required) - **MySQL / Valkey** - Use Ngrok to expose the service ## PostgreSQL: Public Endpoint Miget exposes a public endpoint for PostgreSQL databases. Enable **Public Access** when creating your PostgreSQL service. ### Enable Public Access 1. When creating a PostgreSQL service (standalone or addon), toggle **Public Access** on. 2. For existing databases, go to the service settings and enable public access. ### Connect Using the External URL Once public access is enabled, the **Connection Information** panel displays: - An **External Connection URL** (standard PostgreSQL URI) - A ready-to-run **psql command**, for example: ```bash PGPASSWORD=TMyqX12mvlZy psql -h postgres-service-umlwa.db.eu-east-1.onmiget.com -U l9vhbpir ksm7vspn ``` Use these values for local tools, migrations, or CI jobs. See [PostgreSQL documentation](/databases/postgresql#connecting-from-outside-miget) for more details. --- ## MySQL / Valkey: Using Ngrok For MySQL and Valkey, you can use Ngrok to securely expose services running on private networks to the internet through a public endpoint. ### Prerequisites 1. **Ngrok Free Tier Account** - Sign up at [Ngrok](https://dashboard.ngrok.com/). 2. **Ngrok Authtoken** - Navigate to the [Ngrok dashboard](https://dashboard.ngrok.com/cloud-edge/endpoints) and generate your `NGROK_AUTHTOKEN`. 3. **Miget Database Service** - An existing Miget app with MySQL or Valkey added as a service. ### Get Database Endpoint Once your database service is running: 1. Go to the service details (**Addons → View** on your addon). 2. Copy the service **hostname** and **port number** (click **Show** to reveal credentials and endpoint details). ### Set Up Ngrok Follow the [Connect via Ngrok](/howto/connect/ngrok) guide to deploy Ngrok on Miget. Configure the environment variables with your database hostname and port. ### Connect to Your Database Once you have the public Ngrok endpoint, connect using your preferred client. **MySQL example:** ```bash mysql -h 0.tcp.eu.ngrok.io -P 18227 -u {DATABASE_USER} -p{PASSWORD} {DATABASE_NAME} ``` **Valkey/Redis example:** ```bash redis-cli -h 0.tcp.eu.ngrok.io -p 18227 -a {PASSWORD} ``` Replace `0.tcp.eu.ngrok.io` and `18227` with the values from your Ngrok endpoint. Replace `{DATABASE_USER}`, `{PASSWORD}`, and `{DATABASE_NAME}` with your actual database credentials. ## Summary - **PostgreSQL** - Enable public access and use the external connection URL directly. - **MySQL / Valkey** - Deploy Ngrok on Miget to expose the service and connect via the Ngrok public endpoint.