无法安装和启动mysql,mariadb
最近重新安装了mysql(debian10)
安装失败
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
使用 apt install mariadb-client mariadb-server 安装
遇到了无法安装查看这个大佬博客,也解决了我的重装问题
无法启动
具体问题具体分析
查看日志cat /var/log/syslog
或者service mariadb status
或者systemctl status mariadb
service mariadb status
最后报错的一句话是:
Process: 221080 ExecStartPost=/etc/mysql/debian-start (code=exited, status=2
在cat /var/log/syslog
说是没找到,我一开始以为是文件夹就创建了一个,但是没用,是执行文件!!!
在这里(都是英文,不想看就看我翻译一下)找到答案的
有句话是:For some reason you don’t have the file /etc/mysql/debian-start
出于某种原因你没有文件:/etc/mysql/debian-start
接下来就是介绍如何把这个文件搞到
我使用的方式和原文不同,更加符合使用 apt 安装的实际情况
使用命令apt download tree mariadb-server-10.5
这是我下载安装的mariadb的deb包
你可以输入apt download tree mariadb-server-
尝试按tab键查看
然后 ls
你会发现多了mariadb-server-***.deb
使用dpkg-deb --extract mariadb-server-***.deb /tmp/mariadb-server
解压到 /tmp/mariadb-server 。
/tmp 文件夹系统会自动清理的,专门用来放临时文件
好了,其实你已经得到了debian-start文件,就在/tmp/mariadb-server/etc/debian-start 把它复制过去就可以啦cp /tmp/mariadb-server/etc/debian-start /etc/mysql/
输入service mariadb start
或者systemctl start mariadb
启动成功
最后可以在root下使用`mysql_secure_installation`第一次设置mysql数据库,把它翻译一下总比网上各种修改配置文件方便的多