Automate MySQL to Google Sheets Data Export with n8n Cron

This workflow streamlines exporting data from a MySQL database to Google Sheets automatically every week using n8n’s Cron trigger. By automating this process, it saves users time and eliminates manual errors in data transfer.
cron
mySql
googleSheets
Workflow Identifier: 2411
NODES in Use: Cron, MySQL, Google Sheets

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

Saving Time and Effort: How Sarah Automates Weekly Book Data Export

Sarah manages a growing online bookstore, relying on a MySQL database to store her books’ details. Each week, she needs to export all book data to her Google Sheets for reporting and inventory checks. Doing this manually takes her over an hour each week—copying, saving, and formatting data—which often leads to errors and inconsistencies. Sarah wishes there was a way to automate this repetitive task to reduce mistakes and free her time for more important things.

What This Automation Does

This n8n workflow automates Sarah’s task of exporting her MySQL books data to Google Sheets every week at 5 AM. Here is what happens:

  • The workflow triggers automatically every week at 5 AM via a Cron node.
  • The MySQL node runs a query to select all entries from the books table.
  • The retrieved book data is passed to the Google Sheets node, which appends the data as new rows to a specific Google Sheet.
  • This process eliminates manual copying and pasting, reducing human errors and saving about an hour of manual work per week.
  • The automation ensures data consistency and timely updates to reporting sheets without Sarah lifting a finger.

Overall, this workflow frees Sarah to focus on growing her bookstore rather than tedious data handling.

Prerequisites ⚙️

  • n8n account (cloud or self-hosted) 🔑
  • MySQL database with accessible credentials 🔐
  • Google Sheets account with OAuth access to the target sheet 📊
  • Basic understanding of SQL SELECT queries to modify if needed

Step-by-Step Guide to Build This Workflow

Step 1: Create a Cron Trigger to Schedule Weekly Runs

In n8n, start by adding the Cron node.

Navigate to Nodes Panel → Search > Cron → Add Node.

Set it to trigger weekly at 5 AM by configuring:

  • Mode: Every Week
  • Hour: 5

This sets the workflow to start automatically every week at the specified time. You should see a summary of scheduled triggers after saving.

Common mistake: Forgetting to set the correct timezone in n8n settings can cause unexpected trigger times.

Step 2: Add the MySQL Node to Fetch Book Data

Add a MySQL node after the Cron node.

Set Operation to executeQuery and add the SQL query:

SELECT * FROM books;

This fetches all book records from the database.

Enter your MySQL credentials under the Credentials section. Use an existing MySQL credential or create new ones with hostname, username, password, and database name.

Expected outcome: When executed, the node returns an array of all books as JSON objects.

Common mistake: Incorrect database credentials or network access restrictions can cause connection errors.

Step 3: Append Data to Google Sheets

Add the Google Sheets node and connect it to the output of the MySQL node.

Choose Authentication as OAuth2 and select your Google Sheets OAuth2 credential.

Set operation to append.

Enter the specific Sheet ID where the data should be appended. Example: qwertz (replace with your actual sheet ID).

This node will append the book data rows as new entries in the Google Sheet each time the workflow runs.

Common mistake: Using an incorrect sheet ID or lacking permission will cause write failures.

Customizations ✏️

  • Modify SQL Query: In the MySQL node, update the SELECT statement to filter or sort the books, e.g., SELECT * FROM books WHERE in_stock = 1; to export only available books.
  • Change Trigger Time: Adjust the hour or day in the Cron node to run the workflow at a time that suits your business operations better.
  • Write to Specific Sheet Tab: Add a range or sheet name parameter in the Google Sheets node if you want to write to a specific tab instead of the default.

Troubleshooting 🔧

Problem: “MySQL connection failed”

Cause: Incorrect credentials or database not accessible from n8n host.

Solution: Check and update your MySQL credentials in n8n and ensure the database server allows remote connections from your n8n environment.

Problem: “Google Sheets authentication error”

Cause: OAuth2 token expired or insufficient permissions.

Solution: Re-authenticate the Google Sheets credentials in n8n by removing and re-adding the OAuth2 connection.

Pre-Production Checklist ✅

  • Verify that the Cron node triggers at the correct weekly time in your timezone.
  • Test the MySQL query standalone to confirm it returns the expected data.
  • Ensure Google Sheets credentials have write access to the target sheet.
  • Run the workflow manually to verify data correctly transfers from MySQL to Google Sheets.

Deployment Guide

Once verified, enable the workflow in n8n to run automatically on schedule. Monitor initial runs via the n8n executions panel to confirm success.

For long-term stability, consider setting error notifications in n8n to alert you if the workflow fails.

Conclusion

By building this automation, Sarah now saves at least an hour every week she used to spend manually exporting book data. The process is error-free and hands-off, ensuring her Google Sheets always have fresh data for reporting and tracking.

Next, Sarah could automate inventory alerts, sync sales data, or generate PDF reports — all possible with n8n’s versatile nodes.

Give this workflow a try and see how much time you can reclaim from tedious manual exports!

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation in n8n (Beginner Guide)

A complete beginner guide to building an AI-powered SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free