我正在尝试在arch上使用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并重新安装呢?
答案 0 :(得分:1)
截至7-28-17我必须在新安装时执行此操作。这里的新手可能会节省一些时间。这是一个真正的痛苦。
好的,这是交易!!!!! 安装APACHE _ NO PROB
安装MYSQL _PROBLEM pacman -S mysql然后在启动服务之前
必须取消创意:
nano /etc/mysql/my.cnf
然后必须在启动服务之前初始化datadirectory:
mysql_install_db --user = mysql --basedir = / usr --datadir = / var / lib / mysql
您需要在启动之前初始化MariaDB数据目录 服务。这可以使用mysql_install_db命令完成,例如: mysql_install_db --user = mysql --basedir = / usr --datadir = / var / lib / mysql mariadb的可选依赖项 galera:适用于Galera WSREP的MariaDB集群 perl-dbd-mysql:用于mysqlhotcopy,mysql_convert_table_format和 mysql_setpermission
答案 1 :(得分:1)
第一次安装 MySQL 和 MariaDB 时会发生这种情况。正如 grochmal 所指出的,您必须在第一次使用前设置配置。但是,用户 teckk 在 archlinux newbie corner 中发送了这三个链接:
简而言之,您必须在启动服务之前运行以下命令:
sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
可选地(推荐)您应该improve the initial security 调用:
sudo mysql_secure_installation
现在可以启动服务了:
sudo systemctl start mariadb
或者,您可以安装和使用 graphical front-end tool。 继续按照 archwiki post on MariaDB Configuration 中的说明设置配置。
答案 2 :(得分:0)
如果您正在使用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
删除软件包)
答案 3 :(得分:0)
在Arch Linux中,CNF文件为/etc/mysql/my.cnf
。
我可以重现您的问题的一个简单方法是关闭MariaDB。抱歉,如果它听起来很愚蠢,但你没有提到它:MariaDB是否开始了? sudo systemctl start mysqld.service
你应该看看MariaDB日志以获得一些线索:journalctl _SYSTEMD_UNIT=mysqld.service
(如果你仍然没有得到正在发生的事情,可能粘贴一些部分。)