在 Debian 系统下,MySQL 的启动方式取决于你安装的是 MySQL 还是 MariaDB(Debian 默认常是 MariaDB)。下面分情况说明。
sudo systemctl start mysql
sudo systemctl enable mysql
sudo systemctl status mysql
sudo service mysql start
sudo service mysql status
有时你以为装的是 MySQL,其实是 MariaDB(Debian 默认)。
mysql --version
输出示例:
mysql Ver 8.0.36 for Linux on x86_64 (MySQL Community Server)
mysql Ver 15.1 Distrib 10.11.6-MariaDB
✅ 无论是 MySQL 还是 MariaDB,服务名通常都是
mysql
sudo journalctl -xe
或:
sudo tail -n 50 /var/log/mysql/error.log
/var/lib/mysql 权限错误/etc/mysql/my.cnf 有问题sudo apt update
sudo apt install mysql-server
sudo apt install mariadb-server
如果你愿意,可以贴出:
systemctl status mysql 的输出cat /etc/os-release)我可以帮你具体分析启动失败的原因。