MySQL Workbench and MySQL server 8 is installed in Windows. In my WSL2 prompt, I installed the MySQL 8 client. I want to connect to the MySQL server from WSL2.
When I try mysql -u root -p -h 127.0.0.1 I get
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
On WSL I have "mysql Ver 8.0.21-0ubuntu0.20.04.3 for Linux on x86_64 ((Ubuntu))" installed. If I just try mysql localhost I get
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I believe this is because I don't have the MySQL server installed on WSL just in Windows. I had this working a few days ago but then I had a Windows auto-update and I could no longer connect.
Use windows local ip address instead of 127.0.0.1