【问题标题】:I got ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) with the command sudo mysql on ubuntu我收到错误 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) with the command sudo mysql on ubuntu
【发布时间】:2020-12-18 02:51:00
【问题描述】:

我真的是 php 或 sql 等所有这些东西的菜鸟,所以我参加了 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后能够输入密码

【问题讨论】:

  • 您需要输入您的root密码。你应该在安装 mysql 时被要求创建一个
  • 没有提示我在终端中可以输入密码的任何区域。但是,当我运行 mysql -u root -p 时,我能够输入密码并解决问题
  • 这个答案完全为我解决了:askubuntu.com/a/784347
  • 这个答案为我解决了同样的问题 100%:askubuntu.com/a/784347

标签: php mysql lamp apache2.4 ubuntu-20.04


【解决方案1】:

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

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

【讨论】:

  • 谢谢先生,但我的问题是我无法进入 CLI,没有可以输入密码的区域。但是我的问题已经解决了,我在运行 mysql -u root -p 后就可以输入密码了。
猜你喜欢
  • 2018-08-17
  • 1970-01-01
  • 2022-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-06-25
  • 2021-08-28
  • 1970-01-01
相关资源
最近更新 更多