Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我收到错误1045(28000):拒绝用户访问';根'@';本地主机';(使用密码:否)在ubuntu上使用sudomysql命令_Php_Mysql_Lamp_Apache2.4_Ubuntu 20.04 - Fatal编程技术网

Php 我收到错误1045(28000):拒绝用户访问';根'@';本地主机';(使用密码:否)在ubuntu上使用sudomysql命令

Php 我收到错误1045(28000):拒绝用户访问';根'@';本地主机';(使用密码:否)在ubuntu上使用sudomysql命令,php,mysql,lamp,apache2.4,ubuntu-20.04,Php,Mysql,Lamp,Apache2.4,Ubuntu 20.04,我对php或sql之类的东西都很在行,所以我参加了一个课程,他们让我们安装LAMP 我有Linux和Apache2,但对于MySql,我遵循了本教程。我遵循它,在我们必须运行sudomysql的地方之后,我得到了错误1045(28000):用户'root'@'localhost'的访问被拒绝(使用密码:否)。但根据教程,我应该得到: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id

我对php或sql之类的东西都很在行,所以我参加了一个课程,他们让我们安装LAMP

我有Linux和Apache2,但对于MySql,我遵循了本教程。我遵循它,在我们必须运行
sudomysql
的地方之后,我得到了
错误1045(28000):用户'root'@'localhost'的访问被拒绝(使用密码:否)
。但根据教程,我应该得到:

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> 
请任何人尽快帮我,因为我正在学习的课程有最后期限。如果网上有任何文档,请与我们分享

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

多谢各位


EDIT:我的问题解决了,在运行了
mysql-u root-p

之后,我能够输入密码。请在mysql控制台中尝试以下命令

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

您需要输入您的根密码。在mysql安装过程中,应该要求您创建一个。终端中没有提示我输入密码的任何区域。然而,当我运行mysql-u root-p时,我能够输入密码并解决问题。这个答案完全解决了我的问题:这个答案100%解决了我的问题。同样的问题:谢谢你,先生,但我的问题是我无法进入CLI,那里没有我可以输入密码的区域。但是我的问题解决了,在运行mysql-u root-p之后,我可以输入密码。