How to connect to WSL mysql from Host Windows

前端 未结 3 1279
遇见更好的自我
遇见更好的自我 2021-02-08 16:11

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\'\"

Tr

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-08 16:32

    Since your question is asked before WSL2 release, So I assume you were using WSL1, for WSL1 you can access WSL1 MySQL directly from windows, but you were access in a wrong way, in the NetWork type, you should choose MariaDb or MySQL(TCP/IP) instead of MySQL (SSH Tunnel)

    For WSL2 check this WSL github issue, save @edwindijas's powershell script and execute it by administrator, you may still can not access MySQL , and got access denied for user ... .mshome.net, you need to allow this user access it from this host, let's say root, you need execute this in mysql cli:

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%.mshome.net' IDENTIFIED BY '';

    Or allow root user access WSL2 MySQL from any host:

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password';

提交回复
热议问题