Search code examples
mysqlmariadbdebianwindows-subsystem-for-linuxwindows-11

Connection error with MariaDB under WSL (Debian)


I am using latest Windows 11 build and installed WSL 2 (Debian) for development purpose. To try out a project, I need to install and configure MariaDB under my WSL Debian system. I have installed MariaDB 10.6.5 fine with no errors, but during initial setup process, I am having issues with connecting to MySQL. When I give following command:

sudo mysql_secure_installation

it's showing me error that
ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (2)

I also tried following command:

sudo mysql_secure_installation --protocol=tcp

But it's showing error again
ERROR 2002 (HY000): Can't connect to server on 'localhost' (115)

What's the issue here? How to connect with MySQL under WSL 2?

Note: I don't have MySQL/MariaDB installed under Windows host, only WSL (Debian) has it installed.


Solution

  • Problem solved after stating mariadb service, instead of mysql

    sudo service mariadb start