Connect Google Sheets to MariaDB

Connect Google Sheets to MySQL Database

About MySQL

MySQL is an open-sourced relational database management system with numerous advanced features. Globally renowned to be the most secure and reliable database, MySQL allows for flexibility, scalability, high performance, complete workflow control and much more.

Integrate MySQL

The easiest and fastest way to connect your MySQL database to Google Sheets. With Castodia, you can test the limits by analyzing stored data from relational databases, running and scheduling queries, and auto-refreshing data from a yearly basis down to a 1-minute frequency. Learn more.

[Update: December 2020] Users will no longer need to individually share each sheet with the Castodia service account as described in the video. Users will instead be required to authenticate with their Google Account only once and this will automatically enable auto-refresh for any sheet.

How to Connect MySQL to Google Sheets

Castodia lets you pull data from your MySQL database directly into Google Sheets.

To connect your MySQL database, follow the steps below:

Step 1: Install the Castodia GSuite Marketplace Database Connector

Step 2: Create a Google Sheet and click "Add-Ons" within the toolbar section to access the Castodia Database Connector

Step 3: Two options will appear when you hover over the add-on: launch and settings. Click "Settings."

Step 4: Click the drop-down menu to access the MySQL database

Step 5: Gather and enter your database connection information. There are five components needed:

  • Database Name
  • Host
  • Port
  • Username
  • Password

Step 6: Click the "Test" button to run the database and verify your credentials

Step 7: Click the "Save" button once a green notification pops up, indicating that the add-on was successfully installed.

And that's it! Enjoy running your queries.

Use Case


Suppose a marketing analyst is looking to automate customer data to determine how to approach their upcoming holiday marketing campaign. The company is growing larger so it is no longer effective to manually update CSV files on a weekly basis. The analyst needs a scalable and flexible alternative.

In compiling data, the marketing analyst wants to answer three questions:

  1. Which recurring customers do we have an opportunity to provide additional value to?
  2. What are the impressions, CTR, and conversions of existing email campaigns?
  3. Is there an email subscription growth rate?


Rather than manually exporting CSV files to derive insightful analytics, the marketing analyst can use Castodia's Database Connector to connect their MySQL database to Google Sheets, run and save important queries, and auto-refresh their data every two weeks based on their custom schedule.

To get started, install the Castodia Add-On and access a new Google sheet. Once the MySQL database is connected, you can begin to run SQL queries.

The marketing analyst wanted to automate incoming subscriptions to the company's mailing list. Castodia gives users the freedom to create custom schedule for databases. The marketing analyst can schedule queries to auto-refresh every week on Tuesday and Thursday, with a 2-hour frequency between 8:30 AM and 6:30 PM.

MySQL auto refresh schedule for email marketing
Custom schedule for MySQL

Now let us answer the three marketing questions:

1. Which recurring customers do we have an opportunity to provide additional value to?

First, run a query with the Castodia add-on that will allow you to retrieve the most active customers, indicated by last_seen, by descending order.

Through this simple analysis, the marketing analyst can conclude that for customers who have been active within the 6-month threshold, a drip-email campaign will be launched to create a more personalized experience. For non-active customers, a generic email will be released.

Drip campaign

2. What are the impressions, CTR, and conversions of existing email campaigns?

The marketing analyst can also extract key metrics and KPIs to determine how to approach the upcoming marketing campaign.

Castodia automate email from MySQL data
Visits, clicks, and purchases

By running a query that pulls data regarding impressions, click-through-rate and conversions of existing email campaigns, a bar graph can be created to show the percentage of visits relative to clicks and conversions.

Marketing analyst Castodia add-on MySQL conversion rate
Conversion rate

3. Is there an email subscription growth rate?

Alternatively, the marketing analyst may wonder if prioritizing an email campaign is the most effective way to reach the company's customer base. A comprehensive list of email subscription data pulled from the Castodia add-on can help redirect the campaign's focus.

The data displays an increasing trend of subscriptions, with a recent slight decrease. However, there is potential to reach the company's growing customer base through a well-researched and engaging email campaign.

Subscriber growth rate mysql castodia
Subscriber growth rate


All Castodia Database Connector Features

1 minute auto-refresh

1 Minute Auto-Refresh

Set refresh frequency to every day, every few hours, or every few minutes. Down to once every 1 minute

Advanced scheduling

Advanced Scheduling

Auto refresh data daily, weekly, monthly or yearly with fully customizable schedules

Intuitive UI Castodia

Intuitive UI

Run, save and schedule queries all from within Google Sheets using a clean and intuitive interface

Long query run time

Long Query Time

Run long/complex queries that take minutes to run. Fearlessly run large queries without unexpected errors

Append vs overwrite

Append and Overwrite

Choose how to auto-refresh data on your spreadsheet. Smart Overwrite prevents calculations intact

Direct SQL query

Direct SQL Query

Paste any SQL query and run them directly from Google Sheets. If it runs on your editor it will also run here

Start free trial

Try Castodia free for 14 days, no credit card required.