Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to WSL mysql from Host Windows

I am trying to connect HeidiSql from the host to my WSL Mysql but I could not get it to connect it

Error "can't connect to Mysql server on '127.0.0.1'"

Tried SSH too but could not connect to the server

enter image description here

like image 508
joseph emmanuel Avatar asked Jan 26 '19 09:01

joseph emmanuel


People also ask

How do I access WSL database from Windows?

Go to Settings -> Network and Internet -> Status -> View Hardware and connection properties. Look for the name vEthernet (WSL). It will usually be on the bottom.

How do I find my WSL version?

You can list your installed Linux distributions and check the version of WSL each is set to by entering the command: wsl -l -v in PowerShell or Windows Command Prompt.


Video Answer


2 Answers

I'm also hosting mysql-server on WSL and running MySQL workbench on Windows.

I had to get the IP inside of WSL ifconfig

And use this IP in MySQL Workbench enter image description here

like image 66
Shige Avatar answered Sep 21 '22 14:09

Shige


As for me who's also using WSL for making web based application

first make sure mysql is running on WSL like sudo service mysql start

then once started, open HeidiSql and simply connect to it, here the example on my part

enter image description here

make sure the IP address is 127.0.0.1 not any IP, not your IP used to connect on the internet

like image 44
Fil Avatar answered Sep 19 '22 14:09

Fil