Skip to main content
RapidDev - Software Development Agency
retool-integrationsRetool Native Resource

How to Integrate Retool with MySQL

Connect Retool to MySQL using Retool's native MySQL connector. Enter your host, port, database name, and credentials — with SSL certificate support for cloud-hosted instances on RDS, PlanetScale, and Aurora. Once connected, write SQL queries in Retool's query editor, use GUI mode for safe writes, and build admin panels and reporting dashboards directly on your MySQL database.

What you'll learn

  • How to configure Retool's MySQL resource with host, port, database, credentials, and SSL certificate settings
  • How to write SQL queries with dynamic parameters using Retool's prepared statement syntax
  • How to configure SSL certificates for cloud-hosted MySQL instances on RDS, PlanetScale, and Aurora
  • How to use GUI mode for safe INSERT, UPDATE, and DELETE operations to prevent accidental data loss
  • How to handle MySQL-specific quirks like charset encoding, AUTO_INCREMENT primary keys, and cloud variant differences
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner15 min read15 minutesDatabaseLast updated April 2026RapidDev Engineering Team
TL;DR

Connect Retool to MySQL using Retool's native MySQL connector. Enter your host, port, database name, and credentials — with SSL certificate support for cloud-hosted instances on RDS, PlanetScale, and Aurora. Once connected, write SQL queries in Retool's query editor, use GUI mode for safe writes, and build admin panels and reporting dashboards directly on your MySQL database.

Quick facts about this guide
FactValue
ToolMySQL
CategoryDatabase
MethodRetool Native Resource
DifficultyBeginner
Time required15 minutes
Last updatedApril 2026

Connect Retool to MySQL: From RDS to PlanetScale in Minutes

MySQL powers a huge proportion of the web's applications — from legacy LAMP-stack monoliths to modern cloud-native databases like PlanetScale (serverless, branching-based MySQL) and Amazon Aurora MySQL (high-performance managed MySQL). Teams building internal tools on top of these databases often need dashboards, approval workflows, and data management panels that go beyond what generic MySQL clients like DBeaver or Sequel Pro offer. Retool connects to MySQL natively and turns your database into an interactive application.

Retool's MySQL connector supports SSL certificate authentication required by cloud MySQL providers, charset and collation settings critical for applications with multi-language data, and SSH tunneling for on-premises instances behind corporate firewalls. Unlike PostgreSQL which uses psql's connection string format, MySQL requires individual host/port/database fields — the configuration is straightforward and typically takes under 15 minutes from first login to running queries.

A note for PlanetScale users: PlanetScale deprecated its MySQL protocol support in favor of its HTTP-based driver in 2024 for new connections. However, existing MySQL protocol connections and integrations that rely on the MySQL binary protocol (including Retool's native connector) continue to work. If you are on PlanetScale's newer plans, you may need to connect via their REST API Resource instead. This guide covers both the standard MySQL connector and notes the PlanetScale differences where relevant.

Integration method

Retool Native Resource

Retool includes a dedicated MySQL connector that handles connection pooling, SSL certificate authentication, SSH tunneling, and charset/collation configuration. You configure the connection once in the Resources tab, then write standard MySQL SQL in Retool's query editor. Retool proxies all database connections server-side, so your MySQL credentials and connection details never reach the browser.

Prerequisites

  • A running MySQL instance (version 5.7 or 8.0+ recommended) — on-premises, Amazon RDS, Aurora MySQL, PlanetScale, or another cloud provider
  • A MySQL user account with SELECT permission on the target database (and INSERT/UPDATE/DELETE for write operations)
  • The host, port (default 3306), database name, username, and password for your MySQL instance
  • For cloud MySQL: the SSL certificate authority file (usually downloadable from your cloud provider's console)
  • For on-premises behind a firewall: either Retool's IP ranges whitelisted, or an SSH bastion host accessible from Retool

Step-by-step guide

1

Prepare MySQL user credentials and network access

Before configuring Retool, set up a dedicated MySQL user for the integration and ensure network access is available. In MySQL, create a dedicated user with minimum required permissions rather than using a root or admin account. Connect to your MySQL instance using your admin credentials and run the appropriate GRANT statement. For Retool Cloud connecting to a cloud MySQL instance: add Retool's IP ranges to your MySQL provider's firewall or security group. For Amazon RDS: in the AWS console, navigate to your RDS instance → Connectivity & Security → VPC Security Group → add an inbound rule for port 3306 from Retool's CIDR ranges (35.90.103.132/30 and 44.208.168.68/30 for US West, or your region's ranges). For PlanetScale: in the PlanetScale dashboard, connection access is controlled via connection credentials — create a new password from the Passwords section of your database, selecting the branch you want to connect to. For Google Cloud SQL: use Cloud SQL Auth Proxy for the most secure connection, or add Retool's IPs to the authorized networks list. For on-premises MySQL behind a firewall: configure an SSH tunnel in the Retool resource settings using a bastion host.

create-mysql-user.sql
1-- Create a dedicated Retool user with minimum required permissions
2-- Run this as a MySQL admin or root user
3
4-- Read-only user for dashboards
5CREATE USER 'retool_read'@'%' IDENTIFIED BY 'your_strong_password';
6GRANT SELECT ON your_database.* TO 'retool_read'@'%';
7FLUSH PRIVILEGES;
8
9-- Read-write user for operational tools
10CREATE USER 'retool_app'@'%' IDENTIFIED BY 'your_strong_password';
11GRANT SELECT, INSERT, UPDATE, DELETE ON your_database.* TO 'retool_app'@'%';
12FLUSH PRIVILEGES;

Pro tip: For cloud MySQL providers that enforce SSL, your MySQL user may need to be created with REQUIRE SSL: CREATE USER 'retool_app'@'%' IDENTIFIED BY 'password' REQUIRE SSL; This ensures the connection is always encrypted even if SSL is misconfigured on the client side.

Expected result: A dedicated MySQL user is created with the appropriate permissions, and Retool's IP ranges are added to the instance's firewall allow list.

2

Download SSL certificates for cloud MySQL

Most cloud-hosted MySQL providers require SSL connections and provide CA certificate files for verification. Download the appropriate certificate for your provider before creating the Retool resource. For Amazon RDS and Aurora: download the global-bundle.pem certificate from https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem — this single file covers all RDS regions. For Google Cloud SQL: in the Cloud SQL console, go to your instance → Connections → Security → Download server certificate. Google Cloud SQL also supports client certificates for mutual TLS authentication — download both the server CA and client certificates if required. For PlanetScale: PlanetScale uses Let's Encrypt certificates signed by a trusted CA, so no custom certificate download is needed — just enable 'Use SSL' in Retool. For Vitess: similar to PlanetScale, uses standard TLS certificates. For self-hosted MySQL: if using a self-signed certificate, export the CA certificate in PEM format from your MySQL server configuration. The CA certificate is the one you need for server verification — you are configuring Retool to trust your MySQL server's certificate, not vice versa. Store the certificate contents in a text file ending in .pem ready to paste into Retool.

Pro tip: For RDS, use the global-bundle.pem which chains all regional certificates into one file. This avoids certificate expiration issues when AWS rotates regional certificates.

Expected result: You have the SSL CA certificate PEM file content ready to paste into the Retool resource configuration.

3

Create the MySQL resource in Retool

In Retool, navigate to the Resources tab and click '+ Create new resource'. Select 'MySQL' from the database connectors section. On the configuration screen, fill in: Name — a descriptive label like 'MySQL Production (orders-db)'. Host — the hostname of your MySQL instance. For RDS, this is your-instance.xxxxxxx.us-east-1.rds.amazonaws.com. For PlanetScale, use your database's host from the connection string (format: aws.connect.psdb.cloud). Port — MySQL default is 3306. Some providers (like PlanetScale) use 3306. Database name — the specific database schema to connect to. Username and Password — the dedicated user credentials you created earlier. Charset — set this to 'utf8mb4' for modern applications handling emoji and multi-language characters. The older 'utf8' charset in MySQL is actually 3-byte UTF-8 that cannot handle emoji — always prefer 'utf8mb4'. SSL: toggle on 'Use SSL'. In the SSL configuration section, paste your CA certificate PEM content into the 'Server CA certificate' field. For PlanetScale and RDS with standard certificates, you may not need to paste anything — just enabling SSL with 'Verify server certificate' toggled on is sufficient. Click 'Test connection'. A successful test shows the MySQL version and connection details.

Pro tip: If the test connection fails with an SSL error like 'unable to verify the first certificate', try toggling 'Trust server certificate' on first to confirm connectivity works, then debug the certificate chain separately.

Expected result: The MySQL resource saves successfully and displays a green connected status with the MySQL server version (e.g., MySQL 8.0.35) and the database name confirmed in the test output.

4

Write SQL queries with dynamic parameters

Open your Retool app and create a new query in the Code panel at the bottom. Select your MySQL resource. The query editor defaults to SQL mode. Write standard MySQL SQL using the {{ }} syntax for dynamic parameters — Retool automatically converts these to prepared statements, preventing SQL injection from user-supplied values. MySQL uses ? placeholders in prepared statements internally; Retool handles the conversion transparently when you write {{ componentName.value }}. A few MySQL-specific query patterns to know: MySQL uses LIMIT n OFFSET m for pagination (not OFFSET-FETCH like SQL Server). For auto-increment columns, after an INSERT use LAST_INSERT_ID() to retrieve the generated ID. MySQL uses backticks (`) not square brackets for quoting identifiers with spaces. The NOW() function returns the current timestamp. JSON columns are supported in MySQL 5.7+ with JSON_EXTRACT() or the -> shorthand operator. For the most common pattern — search with filters and pagination — structure your query to check for empty component values so unselected filters do not restrict results.

users-query.sql
1-- MySQL query with dynamic filtering, pagination, and search
2-- Retool compiles {{ }} expressions to prepared statement parameters
3
4SELECT
5 u.id,
6 u.email,
7 u.first_name,
8 u.last_name,
9 u.status,
10 u.created_at,
11 COUNT(o.id) AS order_count,
12 COALESCE(SUM(o.total_amount), 0) AS lifetime_value
13FROM users u
14LEFT JOIN orders o ON u.id = o.user_id
15WHERE
16 ({{ searchInput.value }} = ''
17 OR u.email LIKE CONCAT('%', {{ searchInput.value }}, '%')
18 OR u.first_name LIKE CONCAT('%', {{ searchInput.value }}, '%'))
19 AND ({{ statusFilter.value }} = '' OR u.status = {{ statusFilter.value }})
20 AND u.created_at >= {{ dateRange.start }}
21 AND u.created_at <= {{ dateRange.end }}
22GROUP BY u.id, u.email, u.first_name, u.last_name, u.status, u.created_at
23ORDER BY u.created_at DESC
24LIMIT {{ table1.pageSize }}
25OFFSET {{ (table1.page - 1) * table1.pageSize }};

Pro tip: MySQL's prepared statements treat {{ }} values as data, not SQL fragments. This means you cannot dynamically change column names or ORDER BY direction using prepared statement parameters. For dynamic ORDER BY, use a JavaScript query that constructs different SQL strings based on a sort selection.

Expected result: The query runs and returns rows from your MySQL database as a JSON array. Results appear in the query editor's response panel and can be bound to a Table component using {{ queryName.data }}.

5

Use GUI mode for writes and set up event handlers

For INSERT, UPDATE, and DELETE operations, use Retool's GUI mode rather than raw SQL — it provides a visual interface that prevents accidental WHERE-less updates and generates safe parameterized queries automatically. In the query editor, click the 'GUI' tab next to 'SQL'. Select your Table from the dropdown (Retool introspects your MySQL schema to populate this). Choose the operation: 'Bulk insert a list', 'Update by primary key', 'Bulk update by primary key', 'Delete by primary key', or 'Bulk upsert'. For an Update by primary key operation on a users table: set the Primary Key field to {{ table1.selectedRow.id }}, then add column mappings — status → {{ statusSelect.value }}, updated_at → {{ new Date().toISOString() }}. For an INSERT: set the table to 'users' and map form component values to columns. Wire queries together using event handlers: select your createUser query → Success tab → Add handler → Action: Trigger query → select getUsers (to refresh the table). Add a second handler: Show notification → 'User created successfully'. For the Retool Table component, set Pagination type to 'Server-side' and configure the page size and page variables to match your SQL LIMIT/OFFSET values. For complex MySQL integrations involving stored procedures, triggers, and multi-table transactions, RapidDev's team can help architect and build your Retool solution.

update-user.sql
1-- UPDATE query equivalent of GUI mode output
2-- Shown for reference; in GUI mode this is generated automatically
3
4UPDATE users
5SET
6 status = {{ statusSelect.value }},
7 notes = {{ notesInput.value }},
8 updated_at = NOW(),
9 updated_by = {{ current_user.email }}
10WHERE id = {{ table1.selectedRow.id }}
11LIMIT 1;

Pro tip: Always add LIMIT 1 to UPDATE and DELETE statements in MySQL when targeting a specific row — it acts as a safety net against WHERE clause mistakes that would otherwise affect multiple rows.

Expected result: Write operations execute successfully via GUI mode. The success event handler triggers the data refresh query and shows a success notification. The Table updates to reflect the change without requiring a manual page reload.

Common use cases

Build a user administration panel for a LAMP application

Your web application stores user accounts, subscription data, and activity logs in MySQL. Customer support needs to look up users, update email addresses or subscription statuses, and temporarily disable accounts — without direct database access. The Retool app provides a search interface, an editable user detail form, and a status toggle, all backed by parameterized MySQL queries that prevent direct SQL manipulation.

Retool Prompt

Build a user management panel connected to a MySQL database. Add a search input that queries users by email or name using a parameterized WHERE clause. Show matching users in a Table with columns for id, email, status, and created_at. When a row is selected, show an editable form for email and status. Add Save and Disable Account buttons.

Copy this prompt to try it in Retool

Create an order fulfillment dashboard

Your e-commerce platform stores orders, line items, and shipping information across several MySQL tables. The ops team needs a fulfillment dashboard showing pending orders, with the ability to mark items as shipped, enter tracking numbers, and generate a daily summary of orders by status — replacing a manual spreadsheet process.

Retool Prompt

Build an order fulfillment dashboard. Query orders joined with order_items and customers where status = 'pending'. Show a Table with order ID, customer name, item count, total value, and order date. Add a Mark Shipped button that updates status and inserts a tracking_number. Show a Chart of daily order volume for the last 14 days.

Copy this prompt to try it in Retool

Build a content moderation tool for a MySQL-backed CMS

Your CMS stores blog posts, comments, and user-generated content in MySQL. Moderators need to review flagged content, approve or reject posts, and bulk-delete spam comments — with audit logging for compliance. The Retool app shows flagged items in a queue, displays the content in a preview panel, and records each moderation decision with the moderator's identity.

Retool Prompt

Build a content moderation queue. Query posts and comments where status = 'flagged' ordered by flagged_at desc. Display the content in a Text component when a row is selected. Add Approve and Reject buttons that update the status and insert a moderation_log record with current_user.email and timestamp.

Copy this prompt to try it in Retool

Troubleshooting

SSL connection error: 'unable to verify the first certificate' or 'certificate verify failed'

Cause: The SSL certificate authority chain used by your MySQL server is not trusted by Retool, or you are using a self-signed certificate without uploading the CA cert to the resource settings.

Solution: For Amazon RDS: download the global-bundle.pem from the RDS documentation and paste its contents into the 'Server CA certificate' field in your Retool MySQL resource settings. For PlanetScale: ensure SSL is enabled but the 'Verify server certificate' toggle may need to be off if using PlanetScale's proxy-based connection. For self-signed certs: paste your MySQL server's CA certificate PEM into the Server CA field.

Queries return garbled or question-mark characters for non-ASCII text

Cause: The charset in the MySQL resource configuration does not match the charset used by the database tables. MySQL's default 'utf8' charset is actually limited to 3 bytes and cannot represent emoji or certain Unicode characters. Columns created with 'utf8' collation will have encoding issues.

Solution: Set the Charset field in the Retool MySQL resource to 'utf8mb4'. This ensures the connection uses MySQL's 4-byte UTF-8 encoding that supports the full Unicode range. If underlying table columns use 'utf8' collation, you may also need to migrate the columns to 'utf8mb4_unicode_ci' collation at the database level.

typescript
1-- Check current charset and collation of a table
2SELECT TABLE_COLLATION
3FROM INFORMATION_SCHEMA.TABLES
4WHERE TABLE_SCHEMA = 'your_database'
5AND TABLE_NAME = 'your_table';
6
7-- Alter table to use utf8mb4 if needed
8ALTER TABLE your_table
9 CONVERT TO CHARACTER SET utf8mb4
10 COLLATE utf8mb4_unicode_ci;

INSERT query does not return the new record's ID

Cause: MySQL's INSERT statement does not return the inserted row by default, unlike PostgreSQL's RETURNING clause. Retool cannot automatically surface the auto-increment ID from a standard INSERT.

Solution: After an INSERT in GUI mode, Retool automatically runs SELECT LAST_INSERT_ID() and exposes the value as insertedId in the query result. In SQL mode, add a second query that runs SELECT LAST_INSERT_ID() AS new_id and trigger it on the INSERT query's success event handler.

typescript
1-- Run this as a separate query triggered on INSERT success
2SELECT LAST_INSERT_ID() AS new_id;
3
4-- Access the result in subsequent queries or event handlers:
5-- {{ getLastInsertId.data[0].new_id }}

PlanetScale connection fails with 'SSL connection error' or authentication errors

Cause: PlanetScale connection strings use a branching model where each branch (main, staging) has separate credentials. Using credentials from one branch to connect to another branch fails. PlanetScale also uses a proxy layer that requires specific SSL settings.

Solution: In the PlanetScale dashboard, navigate to your database → Passwords → Create a new password for the specific branch you want to connect to. Copy the hostname, username, password, and database name from the generated connection string. Enable SSL in Retool and set 'Trust server certificate' or use PlanetScale's CA certificate. The hostname format is aws.connect.psdb.cloud and each branch has a unique username.

Best practices

  • Create dedicated MySQL users for Retool with minimum required permissions — a read-only user for reporting dashboards and a separate read-write user for operational tools — rather than using root or admin credentials.
  • Always use 'utf8mb4' as the charset in the Retool MySQL resource configuration to correctly handle multi-byte Unicode characters, emoji, and international text stored in modern MySQL databases.
  • Enable SSL for all cloud-hosted MySQL connections (RDS, Aurora, PlanetScale, Cloud SQL) and upload the appropriate CA certificate to verify the server's identity and encrypt data in transit.
  • Use Retool's GUI mode for INSERT, UPDATE, and DELETE operations on production tables — it generates safe parameterized queries and prevents accidental mass-update statements without WHERE clauses.
  • Add LIMIT 1 to single-row UPDATE and DELETE statements in SQL mode as a safety guard, and consider using a confirmation modal (Popconfirm component) before any write operation that cannot be easily reversed.
  • Use server-side pagination with MySQL's LIMIT/OFFSET syntax rather than fetching all rows and paginating in the Table component — this keeps queries fast as table data grows.
  • For performance-critical queries on large tables, add database indexes on columns used in WHERE, JOIN, and ORDER BY clauses. Use EXPLAIN SELECT ... in a Retool query to inspect the query execution plan and identify missing indexes.

Alternatives

Frequently asked questions

Does Retool support Amazon Aurora MySQL?

Yes. Aurora MySQL is compatible with the MySQL wire protocol, so Retool's MySQL connector works with Aurora MySQL clusters. Use the Aurora Writer Endpoint for read-write connections and the Reader Endpoint for read-only dashboards. Enable SSL and use the RDS global-bundle.pem CA certificate. Aurora MySQL 3.x is compatible with MySQL 8.0, while Aurora MySQL 2.x is compatible with MySQL 5.7.

Can I connect Retool to PlanetScale?

Yes, using the MySQL connector. Create database credentials in the PlanetScale dashboard for the specific branch you want to connect to (main, staging, or a development branch). Use the provided hostname (aws.connect.psdb.cloud), username, password, and database name. Enable SSL in the Retool resource. Note that PlanetScale's branching model means production and staging branches have separate credentials — create separate Retool resources for each environment.

How does Retool prevent SQL injection in MySQL queries?

Retool compiles all {{ }} expressions in SQL queries into prepared statements by default. The parameter values are passed separately from the query text to the MySQL server, which processes them as data — not as SQL code. This means user-supplied values in filter inputs cannot inject SQL commands. You can verify this behavior is active by checking the 'Use prepared statements' toggle in the query's Advanced settings — it should be enabled.

Can I run MySQL stored procedures from Retool?

Yes. Use CALL procedure_name({{ param1.value }}, {{ param2.value }}) in SQL mode. Stored procedures that return result sets via SELECT statements work correctly — Retool captures the output as query.data. For stored procedures with output parameters (OUT/INOUT), use a wrapper approach: call the procedure, then query a session variable or temp table that the procedure populates.

What is the difference between using MySQL vs. Retool Database?

Retool Database is a managed PostgreSQL instance built into Retool with a spreadsheet-like UI and 5 GB of free storage — ideal for Retool-specific data like app configurations, audit logs, or data that does not need to live in your application's database. Your MySQL database is where your application data already lives. Use Retool Database for Retool-native data (like a log of actions taken in Retool apps) and your MySQL database for existing application data.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Integrations are where projects stall

We wire Retool integrations like this one every week — auth, webhooks, edge cases included. Fixed-price builds from $13K, delivered in 6–10 weeks.

Talk to an integration engineer

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.