【问题标题】:Connection error with MariaDB under WSL (Debian)WSL (Debian) 下 MariaDB 的连接错误
【发布时间】:2022-01-07 11:05:00
【问题描述】:

我正在使用最新的 Windows 11 版本并安装了 WSL 2 (Debian) 用于开发目的。 要试用一个项目,我需要在我的 WSL Debian 系统下安装和配置 MariaDB。我已经很好地安装了 MariaDB 10.6.5,没有错误,但是在初始设置过程中,我在连接 MySQL 时遇到了问题。当我给出以下命令时:

sudo mysql_secure_installation

它向我显示错误
ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (2)

我也尝试了以下命令:

sudo mysql_secure_installation --protocol=tcp

但它再次显示错误
ERROR 2002 (HY000): Can't connect to server on 'localhost' (115)

这里有什么问题? WSL 2下如何连接MySQL?

注意:我没有在 Windows 主机下安装 MySQL/MariaDB,只有 WSL (Debian) 安装了它。

【问题讨论】:

  • 正如我所说,我的 Windows 机器上没有 MySQL 客户端或任何东西。这是一台新安装的 Windows 机器,只安装了 WSL。我还尝试了通过 ifconfig 找到 WSL (Debian) 的 IP 连接的方法,例如 172.31.xx.xx,但它也返回相同的错误 - ERROR 2002 (HY000): Can't connect to server on 172.31.xx .xx (115)

标签: mysql mariadb debian windows-subsystem-for-linux windows-11


【解决方案1】:

声明mariadb服务后问题解决,而不是mysql

sudo service mariadb start

【讨论】:

    猜你喜欢
    • 2015-07-07
    • 1970-01-01
    • 1970-01-01
    • 2018-04-30
    • 2019-02-03
    • 2021-06-14
    • 2021-05-03
    • 2017-10-30
    • 2020-03-24
    相关资源
    最近更新 更多