如何在Ubuntu 20.04上重置mysql-server-8.0的root密码?

我刚刚安装了Ubuntu 20.04,并与MySQL搞混了。我不知道如何登录:

$ mysql -u root -p                      
Enter password: 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'

我那里没有任何数据,所以我不在乎数据库是否丢失。实际上,我希望有一个干净的解决方案。

我尝试了什么

dpkg重新配置

This answer:

$ sudo dpkg-reconfigure mysql-server-8.0
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 7577

完成但没有错误消息,但是我看不到任何输入新密码的方法。

mysqld_safe

I tried this, but

$ sudo mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket 
'/var/run/mysqld/mysqld.sock' (2)
$ ls -alh /var/run/mysqld/           
total 0
drwxr-xr-x  2 mysql root   40 Mai 17 11:08 .
drwxr-xr-x 38 root  root 1,1K Mai 17 11:08 ..

我想这可能是个问题?我该怎么办?

完全重新安装

I followed this guide to completely re-install mysql, but I run into the same issues.

评论