DEV Community

Cover image for Connect MySQL Workbench to MySQL Server in WSL using Node
Susan Githaiga
Susan Githaiga

Posted on

Connect MySQL Workbench to MySQL Server in WSL using Node

Windows Subsystem for Linux(WSL) is a Microsoft Windows feature that lets you run a Linux environment directly on your Windows machine without needing a separate virtual machine or dual booting your PC.

WSL uses your window's system IP address as it's own. However, the default MySQL workbench config only accepts requests and connections from 127.0.0.1

If you want to connect your NodeJS app to MySQL workbench, then you need to use the ip address of your host machine(PC). To do this, follow these steps:

  • Open your WSL terminal.

  • Run the following command in your WSL terminal to retrieve your host machine's(PC's) IP address:

ip route show | grep -i default | awk '{ print $3}'

Image description

  • On your .env file, change the DB_HOST(the variable which stores your host IP Address) to your host machine's IP Address

Image description

Now, your NodeJS server is running and ready for use:

Image description

To learn more about how to access your PC's network applications through WSL, read the following article on Microsoft learn: Accessing network applications with WSL

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay