While Google Sheets does provide some impressive features, the capabilities for more advanced Data Visualization and Querying make the transfer from Google Sheets to MySQL Database a useful exercise.

Are you trying to move data from Google Sheets to MySQL to leverage the power of SQL for data analysis, or are you simply looking to back up data from Google Sheets? Whichever is the case, this blog can surely provide some help. 

The article will introduce you to 2 easy methods to move data from Google Sheets to MySQL in real time. Read along to decide which method suits you the best!

Introduction to Google Sheets

Google Sheets is a free web-based spreadsheet program provided by Google. It allows users to create and edit spreadsheets but also, and more importantly, it allows multiple users to collaborate on a single document, seeing your collaborators ’ contributions in real-time simultaneously. It’s part of the Google suite of applications, a collection of free productivity apps owned and maintained by Google.

Despite being free, Google Sheets is a fully functional spreadsheet program, with most of the capabilities and features of more expensive spreadsheet software. Google Sheets is compatible with the most popular spreadsheet formats so that you can continue your work. With Google Sheets, like all Google Drive programs, your files are accessible via computer and/or mobile devices.

To learn more about Google Sheets.

Introduction to MySQL

MySQL is an open-source relational database management system or RDMS, and it is managed using Structured Query Language or SQL, hence its name. MySQL was originally developed and owned by Swedish company MySQL AB, but Sun Microsystems acquired MySQL AB in 2008. In turn, Sun Microsystems was then bought by Oracle two years later, making them the present owners of MySQL.

MySQL is a very popular database program that is used in several equally popular systems such as the LAMP stack (Linux, Apache, MySQL, Perl/PHP/Python), Drupal, and WordPress, just to name a few, and is used by many of the largest and most popular websites, including Facebook, Flickr, Twitter, and Youtube. MySQL is also incredibly versatile as it works on various operating systems and system platforms, from Microsoft Windows to Apple MacOS.

Methods to Set up Google Sheets to MySQL Integration

There are several ways that data can be migrated from Google Sheets to MySQL. A common method to import data from Google Sheets to MySQL is by using the Google Sheets API along with MySQL connectors.  Out of them, these 2 methods are the most feasible:

Load Data from Google Sheets to MySQL
Load Data from Google Ads to MySQL
Load Data from Salesforce to MySQL

Method 1: Using Google Scripts to Set Up Google Sheets to MySQL Integration

This example will explain, how to set up a connection that will create a table and populate it with the data from Google spreadsheets. It is assumed that the data is product listings with 2 columns:

  • Product Name
  • Product Code

Note: Setting up a connection to a MySQL server requires using JDBC (Java Database Connectivity). If you’d like to take a more in-depth look, here’s the link to Google Apps Script JDBC documentation here

The following steps are required to set up the Google Sheets to MySQL Integration:

  • Step 1: To set up a JDBC connection to Google you must first ensure that several IP ranges are added to your SQL server’s whitelist. For the list of IP ranges.
  • Step 2: Obtain the connectivity information for your database. An example would look like this:
    Server: sql.mysite.net
    Database Name: sql123 Username: sqlabc
    Password: P@$w0rd
    Port Number: 3306
  • Step 3: Copy the database details
  • Step 4: Go to your Google Sheet and open the Script Editor.
    1. Open Google Sheet file.
    2. Click Tools -> Script Editor.
Google Sheets to MySQL
Image Source
  • Step 5: Name the Script Editor file (e.g. “MySQLConnection”).
  • Step 6: Apply the database information
    1. A scripting template (Code. gs) will already be loaded. You may delete the content that’s there (Ctrl+A -> Del).
    2. Paste the new content (the database info) into the Code. gs. 
Google Sheets to MySQL
Image Source
  • Step 7: Modify each line to reflect the format below:  
var server = “sql.mysite.net”
var dbName = “sql123”  
var username: “sqlabc”  
var password: “P@$w0rd”  
var port = 3306 
  • Step 8: Create a function to connect Google Sheets to your MySQL database. An example function would be:
function openConnection() {
  var url = “jdbc:mysql://” + server + “:” + port + “/” + dbName;
  var conn = Jdbc.getConnection(url, username, password);
  • Step 9: Create a function to write several records from your Google Sheets file to your MySQL database. For example:
function writeRecords() {
 var sheet = SpreadsheetApp.getActiveSheet();
 var data = sheet.getDataRange().getValues();

 var stmt = conn.prepareStatement('INSERT INTO products ' +  '(productName, productCode) values (?, ?)');

 for (var i = 0; i < data.length; i++) {
  stmt.setString('Product name: ' + data[i][0]);
  stmt.setString('Product number: ' + data[i][1]);
  • Step 10: Add the function to close the connection.

Run the script by pressing the Run Script icon
Note: The first time you run the script you will be asked to provide authorization to Google.

Google Sheets to MySQL
Image Source

Limitations and Challenges of Using Google Script Method to Connect Google Sheet to MySQL

  • As you can see, this is not the easiest of options. As a matter of fact, unless you are a coder or programmer, this is rather complex. Attempting to connect Google Sheets to MySQL using Google Apps Scripts has all of the issues inherent in programming a small applet: you’d need to find and hire someone who knows how to code, and then, given your particular circumstances, they would have to tweak the code to ensure that it does exactly what you want. That takes time and money as the script would have to be tested and tweaked repeatedly.
  • There’s an additional issue with using Google Apps Script. Google has set time limits on script executions. What that means is that if you are attempting to transfer large troves of data, then these transfers may end up being prematurely halted. 
  • Moreover, in case you are looking to clean and transform data before you export Google Sheet to MySQL, you will need to build additional code to cater to that. This adds additional engineering overhead.

Method 2: Using Hevo to Set Up Google Sheets to MySQL Integration

Hevo is the only real-time ELT No-code Data Pipeline platform that cost-effectively automates data pipelines that are flexible to your needs. With integration with 150+ Data Sources (40+ free sources) including Google Sheets, we help you not only export data from sources & load data to the destinations(such as MySQL) but also transform & enrich your data, & make it analysis-ready.

Get Started with Hevo for Free

With Hevo, you can load Google Sheets data to MySQL in 2 simple steps:

  • Configure Data Source: To connect Google Sheets with Hevo, log into your Hevo account and configure Google Sheets as a source as shown in the below image. To learn more about configuring Google Sheets as a data source.
Google Sheets to MySQL: Configuring Google Sheets as Source
Configure Google Sheets Source
  • Configure Destination: To connect MySQL with Hevo, log in to your Hevo account and configure MySQL as a destination as shown in the below image. To learn more details about configuring MySQL as a destination.
Google Sheets to MySQL: Configuring MySQL as Destination
Configure MySQL Destination

Once completed, Hevo will immediately begin migrating data from Google Sheets to MySQL Database, allowing you access to your data in no time.

Advantages of Using Hevo to Connect Google Sheet to MySQL Database

The relative simplicity of using Hevo as a data pipeline platform, coupled with its reliability and consistency, takes the difficulty out of data projects.

You can also read our article about Google Sheets to Google Data Studio.

It was great. All I had to do was do a one-time setup and the pipelines and models worked beautifully. Data was no more the bottleneck

– Abhishek Gadela, Solutions Engineer, Curefit
Deliver smarter, faster insights with your unified data

Using manual scripts and custom code to move data into the warehouse is cumbersome. Changing API endpoints and limits, ad-hoc data preparation, and inconsistent schema makes maintaining such a system a nightmare. Hevo’s reliable no-code data pipeline platform enables you to set up zero-maintenance data pipelines that just work.

  • In-built Transformations – Format your data on the fly with Hevo’s preload transformations using either the drag-and-drop interface, or our nifty Python interface. Generate analysis-ready data in your warehouse using Hevo’s Postload Transformation 
  • Near Real-Time Replication – Get access to near real-time replication for all database sources with log-based replication. For SaaS applications, near real-time replication is subject to API limits.   
  • Auto-Schema Management – Correcting improper schema after the data is loaded into your warehouse is challenging. Hevo automatically maps source schema with destination warehouse so that you don’t face the pain of schema errors.
  • Security – Discover peace with end-to-end encryption and compliance with all major security certifications including HIPAA, GDPR, and SOC-2.

Why Connect Google Sheets to MySQL Database? 

Setting up a connection between MySQL and Google Sheets is a great way to create reports and dashboards for your sales funnel, update and amend data in bulk, and visualize your data.

If your data isn’t connected, you would have to manually export and update your data or copy and paste your MySQL datasets to Google Sheets. In the case of managing large amounts of data, this takes too long. Furthermore, there is a great deal of opportunity for human mistakes in the manual procedure.

By linking your MySQL database to Google Sheets, you may also increase the accessibility of your data for people who are more accustomed to working with spreadsheets than with business intelligence software and SQL.

Here are some of the benefits of connecting Google Sheets to MySQL:

  • Error Reduction: By automating data export processes, the likelihood of human errors diminishes significantly. This helps in maintaining data integrity and accuracy, crucial for effective decision-making.
  • Advanced Analytics: Leveraging MySQL’s robust processing capabilities enables intricate data analysis and complex queries, unlocking insights beyond Google Sheets’ capabilities alone.
  • Data Consolidation: Syncing Google Sheets with MySQL centralizes data from various sources, providing a comprehensive view of operations and ensuring data consistency.
  • Historical Data Analysis: MySQL enables long-term data retention and analysis of historical trends, overcoming Google Sheets’ limitations on historical data.
  • Data Security and Compliance: MySQL’s robust security features ensure data integrity and support advanced governance and compliance requirements.
  • Scalability: MySQL efficiently handles large data volumes, making it suitable for growing businesses managing expanding Google Sheets data.
  • Data Science and Machine Learning: Integrating Google Sheets data with MySQL facilitates the application of machine learning models for predictive analytics and customer segmentation.
  • Reporting and Visualization: MySQL’s integration with advanced visualization tools like Tableau and PowerBI enhances reporting capabilities, offering more sophisticated business intelligence options.
  • Automated Conversion: Tools like Airbyte automate the conversion of Google Sheets tables to MySQL, streamlining the integration process.

Additional Resources on Google Sheets to MYSQL


  • The blog provided a detailed explanation of 2 methods to set up your Google Sheets to MySQL integration.
  • The second method using Google Scripts, although effective, is time-consuming and requires a lot of code. You can use Hevo to import data from Google Sheet to MySQL and handle the ETL process.

Share your experience of connecting Google Sheets to MySQL in the comments section below!

Vernon DaCosta
Freelance Technical Content Writer, Hevo Data

Vernon is enthusiastic about data science and loves to write on diverse topics related to data, software architecture, and integration.

No-code Data Pipeline for MySQL