在 Arch Linux 上全新安装 MySQL 时出现 mysql.sock 不存在错误

标签 mysql mariadb archlinux mysql.sock

我正在尝试在 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/

相关文章:

mysql - MySQL 触发器创建错误 : 1064

mysql - 查询去除字符串中特定长度的字符词?

c - macOS 上的 Pacman fork

php - 如何使用 MySQL 在 PHP 中执行多个更新查询?

java - Spring Boot - “Error creating bean with name 'entityManagerFactory'” - 启动

mysql - 我有两个表 A 和 B。我想使用内部联接将数据从表 B 插入到 A

java - arch linux 中的 mvn clean install 产生许多错误

mysql - 拆分日期并在 mysql 的单独列中插入单个字段

Mysql根据数组列表找到最大列值

mongodb - mongodump archlinux 上的数据库