You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 23.04环境下MySQL安装失败及数据库登录异常求助

Ubuntu 23.04环境下MySQL安装失败及数据库登录异常求助

各位好,我在Ubuntu 23.04的开发桌面机上搭建LAMP栈时遇到了MySQL的棘手问题,想请大家帮忙排查下:

一、登录异常问题

  • 之前我多次安装MySQL都没出过问题,但这次不管怎么弄都没法登录数据库。我创建的用户和权限配置和之前完全一致,目前只能通过Webmin访问数据库,PHP、PHPMyAdmin、HeidiSQL这些客户端全都连不上。
  • 查看/var/log/mysql/error.log,里面只有正常的关机记录,没什么有价值的排查信息,不过有一条截断的警告:root@localhost is created with an empty password ! Please consider switching off the --initialize-inse(后面内容超出了nano的显示范围),但我明明在初次安装时给root设置了密码啊。

二、卸载重装后的报错情况

我试着彻底卸载清理MySQL后重新安装,但还是遇到了报错,操作步骤如下:

卸载清理命令:

sudo apt-get remove --purge mysql* -y
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get dist-upgrade

重装命令:

sudo apt-get -y install mysql-client mysql-server

重装时的错误提示:

ERROR: Database files are locked. Daemon already running? Warning:
Unable to start the server. Created symlink
/etc/systemd/system/multi-user.target.wants/mysql.service →
/lib/systemd/system/mysql.service.
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess
returned error exit status 1 dpkg: dependency problems prevent
configuration of mysql-server: mysql-server depends on
mysql-server-8.0; however: Package mysql-server-8.0 is not
configured yet.
dpkg: error processing package mysql-server (--configure): dependency
problems - leaving unconfigured Processing triggers for man-db
(2.11.2-1) ... No apport report written because the error message
indicates its a followup error from a previous failure.
Processing triggers for libc-bin (2.37-0ubuntu2) ... Errors were encountered while processing: mysql-server-8.0
mysql-server E: Sub-process /usr/bin/dpkg returned an error code (1)

三、当前的困境

之后我又手动停止了MySQL服务,再次执行卸载清理和重装操作,但还是报同样的错误。现在我连终端里都没法登录MySQL来重置root密码——这次重装时根本没弹出设置密码的提示,而且尝试用sudo mysql登录时还会报错:

don@Veriton-L480:~$ sudo mysql
[sudo] password for don:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

备注:内容来源于stack exchange,提问作者DonP

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 16:20:32