The browser reported an error Access denied for user 'root'@'localhost' (using password:NO

browser error: SQLSTATE [HY000] [1045] Access denied for user "root"@"localhost" (using password: NO)
I successfully connected to the database with navicat, the user name is root, password is the password set when installing mysql, and the framework uses tp5,
to find many methods that do not work. How to solve it?

Mar.01,2021

method link seen when encountered earlier: https://bbs.csdn.net/topics/3.


simply understand the meaning of MySQL-Server connections.
from a beginner's point of view, there are two ways to connect MySQL-Server :

1.  Navicat 
2. API  ``

look at your problem, it is very likely that users like root@192.168.%.% set passwords, while root@localhost do not.

 MySQL 

$ mysql -uroot -hlocalhost -p
 -p  Linux 

 mysql 
$ sudo yum -y install mysql

$ sudo apt-get install mysql
 mysql 

 Navicat  root@localhost 
$ SELECT User, Host, Password FROM mysql.user;

by the way, your question is very common, it is not recommended that you ask it directly, it is better to search directly.

Menu