Introduction

Laravel Cloud allows you to create MySQL and Serverless Postgres databases and attach them to your application’s environments directly from the Laravel Cloud dashboard.

Laravel MySQL

Laravel MySQL provides a fully-managed MySQL database for your application. Laravel MySQL databases are assigned a fixed compute and storage size, but can be scaled at any time. Laravel MySQL databases do not currently support hibernation. For information on connecting to your MySQL database from your application or local machine, see Connecting to Database Clusters.

Creating MySQL Databases

To create and attach a MySQL database to an environment:
  1. Navigate to your environment’s infrastructure canvas dashboard
  2. Click “Add database”
  3. Select an existing database cluster or create a new one:
    • To create a new cluster: Select “Laravel MySQL” as your database cluster type and configure:
      • Cluster name: A unique name for your database cluster
      • Instance size: Choose from available compute options (Flex or Pro sizes)
      • Storage: Configure storage from 5GB to 1,000GB
      • Region: Must match your compute cluster’s region
  4. Select an existing database within the cluster or create a new one:
    • Database name: The name of the database within the cluster
You can also create MySQL databases from your organization’s “Resources” page, but they will need to be attached to an environment separately.
Once created, you can attach the database to any environment in the same region. When attaching a database to an environment, you will need to re-deploy the environment for the changes to take effect. Visit the pricing docs for information on compute and storage prices by region.
MySQL databases can only be attached to compute clusters in the same region.

Database Backups

Laravel MySQL databases support automated and manual backups.

Backup Configuration

To configure backups for your MySQL database cluster:
  1. Navigate to “Org > Resources > Databases”
  2. Click on your MySQL cluster
  3. Click “Backups”
  4. Select a backup type:
    • Daily backups: Enable automatic daily backups
    • None: Disable automatic backups

Backup Retention Period

If you select daily backups, you can configure the retention period from 1-30 days. Automatic backups occur during a daily 3-hour backup window, scheduled between 3AM and 6AM EDT.

Manual Backups

You can also create manual backups on-demand from the database cluster’s backup page at any time, regardless of your automatic backup settings.

Restoring from Backups

Backups restore to a new database cluster rather than overwriting the existing cluster. To restore from a backup, select the restore action from the “Restore backup” section. Next, give the restored database a name and select which backup snapshot you want to restore from. Once the backup has been restored, you will now have two database clusters, the original database cluster and a database cluster restored from the backup snapshot you selected. At this point you can either detach the original database from your application and re-attach the restored backup, or connect to each database and selectively restore any missing information you might have. When you no longer need one of the database clusters, you may delete it.

Backup Pricing

Laravel MySQL backup storage is billed separately from database storage:
  • Storage pricing: $0.10/GB-mo (US regions) and $0.12/GB-mo (other regions)
  • Backup pricing: Billed at the same rate as storage pricing
Backups are billed for the amount of gigabyte-months used. Total backup storage is calculated by daily summing up all manual snapshots and automated snapshots, then averaging those values across the billing period. MySQL databases default to 7-day backup retention. You may adjust this retention period or disable backups entirely in your database cluster’s backup settings.

Importing MySQL Data

After enabling your MySQL Public Endpoint, you can use any standard database tools to import your SQL data. For optimal performance, we recommend generating database dumps with the --skip-extended-insert option, especially for smaller Laravel MySQL instances, to reduce memory usage. The following tools offer efficient and reliable database imports, particularly for larger datasets: These tools support parallel execution, making them significantly faster than the traditional mysqldump and mysql commands when handling large databases. Additionally, GUI-based tools like TablePlus can be used for imports. However, be aware that smaller Laravel MySQL instances may encounter memory limitations when using such tools.

Database Sizing and Performance

Choosing the Right Database Size

Several key factors influence the right database size for your workload: connection requirements, queue workload, backup retention needs, and planned database migrations.
Connection Limits
The amount of RAM your database has determines how many simultaneous connections it can support:
Server MemoryMySQL Connection Limit
512 MB51
1 GB102
2 GB204
4 GB408
8 GB816
16 GB1,632
32 GB3,264
All databases are fronted by a proxy layer in Laravel Cloud, which helps multiplex connections for read-only queries, enabling up to 10,000 connections in some conditions. However, writes and transactions cannot be multiplexed—those will count against your MySQL connection limit. Plan your size based on your expected read/write mix.
Queue Workload Considerations
If your application runs queue workers with a low --sleep interval (such as --sleep=1 or lower), expect high CPU usage. That’s acceptable for development environments, but in production, we recommend a minimum of 2 vCPUs, possibly more for high-throughput jobs.
Backup Retention Planning
Backups are essential—especially for production databases. If you’re working with a disposable or development database, it’s fine to set the retention period to 0 days. For anything else, we recommend at least 2 days of backup retention for basic protection and recovery.
Database Migrations and Imports
Planning to transfer or import a database? You may need to temporarily scale up your database’s CPU and memory to handle large or fast MySQL imports.
  • CPU and memory can be scaled up and down easily
  • Storage size can only be increased—not decreased—so plan for long-term needs before import
For smoother imports, consider using optimized dump commands:
mysqldump -u USER -h HOSTNAME -p'PASSWORD' --single-transaction --set-gtid-purged=OFF --databases my_database > backup_my_database.sql

Database Upgrades

Laravel MySQL databases created before July 2, 2025 require an upgrade to access backup functionality. To check if your database requires an upgrade, click the ”…” menu for your database cluster. If an “Upgrade Database” option is present, an upgrade is required. To upgrade your database:
  1. Navigate to “Org > Resources > Databases”
  2. Click on your MySQL cluster
  3. Click the ”…” menu and select “Upgrade Database”
  4. Confirm the upgrade
The upgrade process will cause several minutes of downtime depending on your database size. Databases not manually upgraded by October 1, 2025 will be automatically upgraded during the next maintenance window.
Backups are not visible in the UI for databases that have not been upgraded. Contact support if you need assistance with backups for non-upgraded databases.

Troubleshooting

Common Error Messages

Too Many Connections Error
SQLSTATE[HY000]: General error: 1040 Too many connections
Solution: Increase your database RAM, decrease the number of replicas your app has, or contact support. You may have exceeded the connection limit or have a database query that has locked the database requiring a restart.
Connection Timeout Error
SQLSTATE[HY000]: General error: 9001 Max connect timeout reached while reaching hostgroup...
Solutions:
  • If this message appears constantly, confirm you have plenty of disk space and allow 15 minutes for the database to restart after changing disk space limits
  • Check notifications to be alerted before reaching these limits
  • If this message appears occasionally, you may need to increase your database RAM as the database likely hit an out-of-memory error and restarted during a query or connection burst
  • Contact support if issues persist

Performance Monitoring

Monitor your database performance through the metrics dashboard available in your database cluster settings. Watch for:
  • High CPU usage: May indicate inefficient queries or insufficient compute resources
  • High memory usage: Could lead to connection issues or query failures
  • Low disk space: Can cause database failures and connection timeouts
Enable notifications in your organization settings to receive alerts before reaching resource limits.

Laravel Serverless Postgres

Powered by Neon
Laravel Serverless Postgres provides a full-managed, autoscaling and serverless Postgres database for your application. Serverless Postgres databases autoscale their compute resources and storage to automatically accommodate the demand from your application. To attach a Serverless Postgres database to an environment, click “Add database” on your environment’s infrastructure canvas dashboard. When adding a database to an environment, Laravel Cloud will prompt you to select the database you would like to attach to the environment or to create a new database cluster. When creating a new cluster, select “Laravel Serverless Postgres” as your database cluster type.
Once the database has been attached to an environment, you will need to re-deploy the environment in order for the changes to take effect.

Compute Units

When creating a Laravel Serverless Postgres database cluster, you may configure the range of “compute units” your cluster should scale between based on demand. Compute units correspond to the following vCPU / RAM configurations:
Compute UnitsvCPUsRAM
.25.251 GB
.5.52 GB
114 GB
228 GB
3312 GB
4416 GB

Connection Pooler

Laravel Serverless Postgres offers connection pooling via pgbouncer, enabling up to 10,000 concurrent connections to your cluster. To connect to the pgbouncer endpoint of your database cluster, append -pooler to the first segment of the cluster’s host name. For example, if your database cluster’s host name is ep-frosty-shadow-a57j6ubb.us-east-2.pg.laravel.cloud, the corresponding pgbouncer endpoint is ep-frosty-shadow-a57j6ubb-pooler.us-east-2.pg.laravel.cloud. Then, add the new host name as the DB_HOST environment variable in your environment’s General Settings:
DB_HOST="frosty-shadow-a57j6ubb-pooler.us-east-2.pg.laravel.cloud"

Hibernation

Laravel Serverless Postgres databases may be configured to automatically hibernate after not receiving any incoming database queries for a given number of seconds. When a Serverless Postgres database is hibernating, you will not be billed for its compute resources. If the database receives an incoming query while it is hibernating, the database will automatically wake up within a few hundred milliseconds.

Autoscaling Compute

Serverless compute can autoscale up and down based on your database cluster’s utilization. Set a minimum and maximum range and only pay for the compute resources you actually need.

Database Clusters vs. Databases

When creating a new database cluster, you will be asked to provide the desired name of the cluster and the desired name of the initial “database” that will be created within the cluster. Each database cluster can have as many databases as needed within the cluster. In web development, these databases are sometimes referred to as “schemas”. When attaching a database cluster to an environment, you will actually be selecting a particular database within the cluster that you would like to make available to the environment via the DB_DATABASE environment variable used by Laravel.

Connecting to Database Clusters

From Your Application

When a database is attached to an environment, Laravel Cloud will automatically inject the environment variables needed by the Laravel application to connect to the database, including the DB_HOST, DB_USERNAME, DB_PASSWORD, and DB_DATABASE variables. You may view these environment variables in your environment’s General Settings.

From Your Local Machine

To connect to your database from your local machine using a database management client like TablePlus, navigate to your organization’s “Resources” page and click the ”…” icon next to an available database. Then, click “View credentials”.
The database credentials modal window will provide you with the credentials needed to connect to your database, in addition to a “DeepLink” which will open your database in your local machine’s default database management client if you have one installed.

Postgres SSL Connections

Neon, which powers Laravel Serverless Postgres, uses the public ISRG Root X1 certificate issued by Let’s Encrypt. Due to this, you can create an SSL Connection with your Postgres cluster by using the appropriate CA certificate for your operating system. If you are using macOS, this certificate should already be located within your /etc/ssl/cert.pem path.

MySQL Public Endpoints

Before connecting to a MySQL database cluster, you must enable its public endpoint. From your organization’s “Resources” page, navigate to the “Databases” tab and click the ”…” icon for the MySQL database cluster you would like to connect to. Then, click “Edit settings” and enable the “Enable public endpoint” toggle. Once the public endpoint has been enabled, you may click the ”…” icon next to the MySQL database cluster and click “View credentials”. When you are finished interacting with your database from your local machine, you are free to disable the public endpoint.

MySQL SSL Connections

To connect to MySQL databases that require SSL, you should add the following environment variable to your application:
MYSQL_ATTR_SSL_CA="/etc/ssl/certs/ca-certificates.crt"

Editing and Resizing Database Clusters

To edit your database clusters and adjust their compute / storage settings, navigate to “Org > Resources > Databases” and click the ”…” icon for the database cluster you would like to edit or resize. Then, click “Edit settings”.
Laravel MySQL storage can only be increased once every 6 hours and cannot be decreased.

Database Cluster Metrics

To view metrics such as CPU, write throughput, and storage for database clusters, navigate to “Org > Resources > Databases”, click the database cluster card, and click the “Metrics” option.

Deleting Database Clusters

To delete a database cluster, navigate to “Org > Resources > Databases” and click the ”…” icon for the database cluster you would like to delete. Then, click “Delete” and confirm your action.