我收到错误104528000:在ubuntu上使用命令sudo mysql对用户'root'@'localhost'使用密码:NO的访问被拒绝

问题描述

在诸如PHPsql之类的所有东西中,我真的是菜鸟,所以我参加了Coursera课程,他们告诉我们安装LAMP。

我有Linux和Apache2,但是对于MysqL,我遵循了本教程how to install LAMP。我遵循了它,在必须运行sudo MysqL的地方之后,我得到了ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)。但是根据教程,我应该得到:

Welcome to the MysqL monitor.  Commands end with ; or \g.
Your MysqL connection id is 22
Server version: 8.0.19-0ubuntu5 (Ubuntu)

copyright (c) 2000,2020,Oracle and/or its affiliates. All rights reserved.

Oracle is a registered Trademark of Oracle Corporation and/or its
affiliates. Other names may be Trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MysqL> 

请任何人尽快帮助我,因为我正在做的课程有最后期限。另外,如果网络上有任何可用的文档,请共享。

如果您需要有关该错误的更多信息,请告诉我以及如何提取它们。

谢谢。

编辑:我的问题已解决,我在运行MysqL -u root -p

后能够输入密码

解决方法

您好,请在mysql控制台中尝试以下命令

mysql>  FLUSH PRIVILEGES;
mysql>  ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';