我正在尝试在 Arch Linux 上使用 MySQL
。它已经安装,但当我尝试连接时出现此错误:
connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2 "No such file or directory")'
我已经查找了 /etc/my.cfg
但该文件不存在。
安装过程中肯定出了什么问题。
如何“清除”MariaDB
并重新安装它?
最佳答案
如果您正在使用 archlinux
,了解包管理器 (pacman
) 是一个重要的想法。关于/etc/my.cfg
的问题可以运行
pacman -Ql mariadb
在那里您会看到该文件实际上被称为:
/etc/mysql/my.cnf
Arch linux 不会为您配置软件包,这是arch 理念的一部分。它将提供示例配置,甚至为您提供一个 systemd
单元文件
usr/lib/systemd/system/mysqld.service
但您有责任确保配置正确并实际启动守护进程。
systemctl enable mysqld # add the unit file to the boot sequence
systemctl start mysqld # runs ExecStart= in the unit file
systemctl stop mysqld # kills the daemon
systemctl disable mysqld # remove unit from boot sequence
重新安装
因为重新安装这个词在问题的标题中并且有人可能会发现这个问题多亏了:要重新安装 mariadb
你只需做
pacman -S mariadb
pacman
会重新安装已经安装的包,不需要删除包(为了完整起见,包删除发生在 pacman -R
)
关于在 Arch Linux 上全新安装 MySQL 时出现 mysql.sock 不存在错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37684130/