No items found.

Easily replicate data from MySQL to BigQuery

Learn how to easily replicate your data from MySQL to BigQuery, where it can be combined with data from other sources to get a holistic view of your business.

According to DB-engines Rankings, MySQL is the second most popular database. On the other hand, BigQuery is Google’s cost-effective, serverless, multi cloud enterprise data warehouse. Copying data from MySQL to BigQuery may be part of your overall data integration strategy, that will provide you with the following benefits:

  1. Fast analytics without impacting operational workloads: BigQuery is designed for fast and efficient analytics. Furthermore, by creating a copy of your operational data, you can execute complex analytical queries without impacting your operational workloads.
  2. Creating a single source of truth and optimize reporting workflows: It can be time-consuming and challenging for analysts to work with multiple platforms. Combining data into a centralized data warehouse reduces this workload by serving as a single source of truth.
  3. Improved security: Replicating data out of MySQL into an analytical system such as BigQuery removes the need to grant permissions to data analysts on operational systems, which can improve security. 
  4. Data insights that go deeper: MySQL is built for OLTP (Online Transaction Processing) operations well, while BigQuery handles OLAP (Online Analytical Processing). BigQuery is a serverless, cost-effective, multi-cloud data warehouse that can help you quickly turn big data into valuable insights.

This tutorial will show you how to use Airbyte cloud, which is a data integration platform, to set up a data replication pipeline from MySQL to BigQuery.

Let's get started!


To follow the steps provided in this tutorial article you will make use of the following tools.

In this tutorial, you will set up the MySQL database on Microsoft Azure cloud. This is because the Airbyte cloud will make use of a public (not local) IP address to access MySQL. On the other hand, If you want to connect Airbyte to a local instance of MySQL, you may consider downloading and running Airbyte open-source.

Step 1: Set up MySQL as an Airbyte source

Create a MySQL server on the Azure cloud platform, and follow the Quickstart: Create an Azure Database for MySQL server by using the Azure portal

ℹ️ We use the Azure cloud platform for this tutorial, but you can set up MySQL on any cloud platform you prefer.

Once the server set-up process is complete, open the server dashboard. On the side panel, click the connect button to open up the connection settings and copy the details. We will use them to connect with MySQL workbench, which will serve as the client from which we will build a test database with sample data.

Step 2: Connect MySQL workbench to MySQL server

Open your MySQL workbench and follow the steps to connect it to MySQL server, as instructed in: Quickstart: Use MySQL Workbench to connect and query data in Azure Database for MySQL

If the above configuration is successful, your MySQL workbench is connected to your instance of MySQL. You can create and access some test data, which will be used to demonstrate Airbyte replication to BigQuery. 

Step 3: Set up the MySQL database as a data source on Airbyte Cloud

Log in to your airbyte cloud account, click on the sources tab, and then the +new source button to create a new source.  On the Source type, select MySQL, then complete the details to match the settings you defined when you set up MySQL. This should look similar to the image shown below: 

Step 4: Set up BigQuery

To set up BigQuery, access your account on the google developer console and create a new project. In your newly created project dashboard, click on the navigation menu on the right side and select “IAM & ADMIN” - Service Accounts.

Click on Create Service Account to create a service account. In the setup window, define your service account name, ID and click create to complete the setup process.

Setup the storage object admin role. On the Roles’ setup prompt that follows, search for cloud storage service and then select Storage Object Admin role. Click on done to finish the setup process.

Create a Cloud Storage bucket that will hold your data on BigQuery. Follow the steps below to create a storage bucket. On your project dashboard, search for Cloud Storage on the search bar and select it. Next, click the Create Bucket button to set up your storage bucket. Then provide the following information:

  1. Bucket Name. Enter a name for your bucket.
  2. Your data Location: The default option is US (multiple Regions in US).
  3. Your data storage class: Select the default standard option.
  4. Access control: Select the default Uniform option.
  5. Data Protection: Select the default none option.

Finally, click on create to finish the setup process. Follow the steps below to create an HMAC key access ID and Secret, which will be used later in Airbyte. After creating your storage bucket, navigate to the bucket dashboard and click on the settings option followed by Interoperability.

Click on create a key for a service account to select the service account initially created.

Finally, click on Create key to create your HMAC Access Key and Secret.

Copy the HMAC access key and secret. You will use it in the last step of setting up a connection between Airbyte cloud and BigQuery.

Step 5: Set up BigQuery as an airbyte destination

Log in to your Airbyte cloud account to set up the connection to the destination. Click Destinations and then click + New destination and select BigQuery as the destination to start the destination setup prompt. Configure the following details to set up the destination on airbyte:

  1. Destination type: BigQuery
  2. Destination name: BigQuery.
  3. Project ID: The project ID you initially set when creating your project on the Google console.
  4. Dataset location: Select the location of your BigQuery dataset.
  5. Dataset Id: Your dataset ID.
  6. Loading method: Airbyte recommends GCS staging.
  7. Service Account Key JSON. Enter the Google Cloud Service Account Key in JSON format.
  8. Transformation Query Run Type: Set the default interactive to have BigQuery run interactive query jobs.
  9. Google BigQuery Client Chunk Size: Set the default value of 15 MiB.

This should look similar to the following: 

Click on the setup connection button, at which point the connection to the BigQuery destination will be verified.  

Step 5: Sync data using Airbyte Cloud

The last step in this process is establishing a connection between the source and destination. Click on Connections on the left tab, and then click on + New connection. Then select the MySQL source that you just created, followed by the new BigQuery destination. At this point you should see a screen similar to the following:

Give the new connection a name, and define the replication frequency. At the bottom of the above screen, you will see a list of the tables (not shown) that are available in your source, and can select the Sync mode for each one.  If you are not sure which Sync mode (a.k.a. replication mode) to choose, you may wish to read our blog on replication modes

Once you start the first sync, your data from MySQL will be replicated to BigQuery

Log in to your Google developer console and navigate to your project to see the results of the first sync. In the image below, data has been replicated from a vehicles table into BigQuery – but the data you see will depend on your MySQL source data, and the tables that you have chosen to replicate.

Step 6: Wrapping up 

In this step to step tutorial, you have learned how to:

  1. Configure a MySQL data source
  2. Configure BigQuery as a destination
  3. Create an Airbyte cloud connection that syncs data from MySQL to BigQuery

Airbyte’s data integration platform makes it easy to move data from across your enterprise into a single source of truth that is optimized for analytics! This has several benefits including: improved analytics, a single source of truth, improved security, and better data insights. If you have enjoyed this tutorial, you may check out Airbyte's tutorials and Airbyte’s blog to learn more about the platform. You can also join the conversation on our community Slack Channel, participate in discussions on Airbyte’s discourse, or sign up for our newsletter

Similar use cases

Replicate Salesforce and Zendesk data to Keen for unified analytics

Learn how to replicate data from Salesforce and Zendesk to Keen to gain a 360-degree view of your business using Airbyte.

Visualize the time spent by your team in Zoom calls

Learn how to visualize how much time your team is spending in Zoom calls with the Airbyte Zoom connector and Tableau.

Build a single customer view with open-source tools

Learn how to use a data integration tool (Airbyte) and a data transformation tool (dbt) to create a single customer view on a data warehouse (BigQuery).