GVKun编程网logo

警告: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) 连接问题

12

如果您想了解警告:mysqli_connect():(HY000/1045):Accessdeniedforuser'root'@'localhost'(usingpassword:NO)连接问题的知

如果您想了解警告: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) 连接问题的知识,那么本篇文章将是您的不二之选。同时我们将深入剖析006 - 解决 ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using passwo...、1045-Access denied for user ''root''@''localhost'' (using password:YES)、Centos7解决MySQL登录ERROR 1045 (28000): Access denied for user ‘‘@‘localhost‘ (using passwor)问题、ERROR 1045 (28000): Access denied for user ''mysql''@''localhost'' (using password: YES的各个方面,并给出实际的案例分析,希望能帮助到您!

本文目录一览:

警告: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) 连接问题

警告: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) 连接问题

如何解决警告: mysqli_connect(): (HY000/1045): Access denied for user ''root''@''localhost'' (using password: NO) 连接问题?

这是我的 PHP 代码。

    <?PHP
$conn = MysqLi_connect("localhost","root",'''',"sensor");
if ($conn)
{
    MysqLi_set_charset($conn,"utf8");
    
    $q= "select * from temper";
    $result=MysqLi_query($conn,$q);
    
    while($row = MysqLi_fetch_assoc($result)){
        $output[] = $row;
        
    }
    
    echo json_encode($output);
        
    MysqLi_close($conn);
    
} else{
    echo "probleme de connexion";
}

?>

某人:说拒绝访问意味着身份验证失败。这意味着存在无效的用户名或密码组合。对于sql,很明显用户可以是root。因此,请转到您的 PHPMyAdmin 并从用户选项卡中查看。您可能会发现在 root 帐户上设置的密码。而且通常在线数据库总是受密码保护。

我检查了用户选项卡中的用户名和密码,他们说: 用户名:root 主机名:本地主机 密码:否

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

006 - 解决 ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using passwo...

006 - 解决 ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using passwo...

本文转载自:https://blog.csdn.net/hua1011161696/article/details/80666025

解决方案:

    步骤一:关闭数据库服务端 mysqld 程序

两种方式:

①快捷键 windows + R     ;输入 services.msc  ;   找到 MySQL  停止其服务(前提是你之前已经把 MySQL 加入了系统服务中)

 

②在命令行程序中;注意需要以管理员权限运行 cmd 程序,不然无法关闭 mysqld 进程

>>tasklist |findstr mysqld        这行命令可以用来查看 mysqld 是否在运行,在运行中则可以查到它的 PID

>>taskkill /F/PID xxxx             xxxx 是从前面一条命令得到的 PID 值

 

步骤二:跳过权限登录 MySQL 服务器端

在 cmd 中执行 mysqld --skip-grant-tables 

>>mysqld --skip-grant-tables

 

此时 cmd 程序会阻塞,关闭 cmd 程序 然后重新以管理员权限运行 cmd

然后在 cmd 命令行中输入 mysql 就能连接上 MySQL 服务器端了

>>mysql

然后可以通过 sql 语句 :SELECT * from mysql.user\G;  来查看服务器端所有的用户信息,重点查看 User、Password、authentication_string 这三项。这条语句非常关键。

步骤三:修改密码

 依次执行如下 sql 语句:

update mysql.user set authentication_string=password(''321'') where user = ''root'';
flush privileges;
上面第一条 sql 语句中 password ('' 密码 '') 函数中写你想要改成的密码,我这用的是密码 321

接着执行:

SELECT * from mysql.user\G;
去找到 root 用户的 authentication_string 这项,并把它的值记下来。

MySQL 会给密码进行加密,你想要设置的密码进行加密后的值就等于此时 authentication_string 这项的值

所以接下来把 Password 这项的值也设置成此时 authentication_string 项的值就 ok 了;我设置的密码是 321 ,其对应的密文是  *7297C3E22DEB91303FC493303A8158AD4231F486

执行下面两条 sql 语句:

update mysql.user set password = ''*7297C3E22DEB91303FC493303A8158AD4231F486'' where user = ''root'';
flush privileges;


步骤四:

输入 quit 退出 mysql ;然后就可以直接登录了

>>mysql -u root -p

--------------------------------------------------------------------------------

当然也可以重启下 mysqld 再登录
再次提醒:需要以管理员权限运行 cmd
>>tasklist |findstr mysqld
>>taskkill /F /PID xxxx

然后就是启动 mysqld 程序
(不知怎么把 mysqld 加入系统服务中去可看点击打开链接)
>>mysqld

若已经把 mysqld 程序加入了系统服务中,则需要在系统服务中启动 MySQL 服务端

快捷键 windows + R     ;输入 services.msc  ;

 

最后就是重新登录

>>mysql -u root -p

在 Password:处填入你前面设置的密码

补充:修改密码时报语法错误解决方法

问题:

mysql> update mysql.user set authentication_string=password(''321'') where user = ''root'';

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''(''321'') where user = ''root'''' at line 1

解决方法:

使用如下语句即可解决

alter user ''root''@''localhost'' identified by  ''123'';

1045-Access denied for user ''root''@''localhost'' (using password:YES)

1045-Access denied for user ''root''@''localhost'' (using password:YES)

之前重新修改过MySQL密码,运行的好好的,今天打开就出问题:

1130-Host ''localhost'' is not allowed to connect to this MySql server

并且打开MySQL Command Line Client,输入前几天设定的密码窗口关闭,

在网上查找改来改去不行,又重新设置密码

1.关闭正在运行的MySQL。

2.打开DOS窗口,转到mysql\bin目录。

3.输入mysqld --skip-grant-tables回车。

4.再开一个DOS窗口,转到mysql\bin目录。

5.输入mysql回车,如果成功,将出现MySQL提示符 >

6. 连接权限数据库>use mysql; (>是本来就有的提示符,别忘了最后的分号)

6.改密码:> update user set password=password("520") where user="root"; (别忘了最后的分号)

7.刷新权限(必须的步骤)>flush privileges;

8.退出 > \q

修改后打开MySQL Command Line Client,输入密码可以连接数据库,但是

Navicat报错1045-Access denied for user ''root''@''localhost'' (using password:YES)

按照这个方法:

1. 管理员登陆系统,停止mysql服务或者结束mysqld-nt进程
2. 进入命令行,来到mysql的安装目录.假设安装目录为 d:\mysql\ , CMD进入命令行
3. 运行 d:\mysql\bin\mysqld-nt --skip-grant-tables 启动mysql,关闭权限的检查
4. 运行 d:\mysql\bin\mysqladmin -u root flush-privileges password "newpassword" 重设root密码
5. 重新启动mysql服务

又变回开始的时候,然后我又重设密码,Navicat报错1045,真是醉了

求大神指导!!




Centos7解决MySQL登录ERROR 1045 (28000): Access denied for user ‘‘@‘localhost‘ (using passwor)问题

Centos7解决MySQL登录ERROR 1045 (28000): Access denied for user ‘‘@‘localhost‘ (using passwor)问题

登录数据库时,发现数据库连接不上,报错如下:

ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using passwor:yes)

为了以后方便排查,这里记录一下。

首先,停止MySQL服务

systemctl stop mysqld.service

既然是密码错误,那么就先跳过密码验证的步骤

vim /etc/my.cnf

然后,搜索mysqld,找到[mysqld](port=3306上面那个):

/mysqld(在vim编辑状态下直接输入该命令可搜索文本内容)。

注:windows下修改的是my.ini。

在 [mysqld] 底下添加语句:

skip-grant-tables

(注:skip-grant-tables:不启动grant-tables授权表,作为启动参数的作用:MYSQL服务器不加载权限判断,任何用户都能访问数据库)

这是用来跳过密码验证的,添加之后保存退出。

重新启动MySQL服务

systemctl restart mysqld.service
 

进入MySQL

mysql -u root -p

出现密码输入时,不用输入直接按回车,就可以不用密码就能登录修改密码

使用mysql数据库

use mysql;
mysql> update user set password=password("newpassword") where user="root";

如果报错:

ERROR 1054(42S22) Unknown column ''password'' in ''field list''

原因: 5.7版本下的mysql数据库下已经没有password这个字段了,password字段改成了authentication_string

  1. mysql> update user set authentication_string=password("newpassword") where user="root";

  2.  
  3. #刷新MySQL权限相关的表

  4. mysql> flush privileges;

  5. mysql> exit;

密码修改完毕

vim /etc/my.cnf

编辑my.cnf(Windows下my.ini),将上面添加的内容去掉(skip-grant-tables)。

重启MySQL

systemctl restart mysqld.service
 

使用新密码登录即可

 

Buy me a cup of coffee :)

ERROR 1045 (28000): Access denied for user ''mysql''@''localhost'' (using password: YES

ERROR 1045 (28000): Access denied for user ''mysql''@''localhost'' (using password: YES

解决方法:

利用 mysql 安装时的默认用户名登录 mysql 后, 输入以下命令修改 root 密码

mysql> ALTER USER ''root''@''localhost'' IDENTIFIED BY ''MyNewPass''

2. 授予用户权限 

GRANT ALL PRIVILEGES ON *.* TO ''jiang''@''%'' IDENTIFIED BY ''1'';
flush privileges;


 

下面的内容没有用到

 

 

一。有时可以直接输入命令: mysql 进入数据库

启动数据库:# mysqld_safe &

二。查看用户命令: 

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select host,user from mysql.user;//show databases;

+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+

4 rows in set (0.00 sec)

mysql>

 删除用户

   

mysql>Delete FROM user Where User=''test'' and Host=''localhost'';

   mysql>flush privileges;

   mysql>drop database testDB; //删除用户的数据库

删除账户及权限:>drop user 用户名@''%'';

        >drop user 用户名@ localhost;

创建用户

mysql> create user ''root''@''%'' identified by ''1'';#  %代表所有端口
Query OK, 0 rows affected (0.07 sec)

mysql> select host,user from mysql.user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| %         | root             |
| %         | usrabc           |
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
+-----------+------------------+
5 rows in set (0.00 sec)

查看数据库列表:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)

mysql>

 

今天关于警告: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: NO) 连接问题的介绍到此结束,谢谢您的阅读,有关006 - 解决 ERROR 1045 (28000): Access denied for user ''root''@''localhost'' (using passwo...、1045-Access denied for user ''root''@''localhost'' (using password:YES)、Centos7解决MySQL登录ERROR 1045 (28000): Access denied for user ‘‘@‘localhost‘ (using passwor)问题、ERROR 1045 (28000): Access denied for user ''mysql''@''localhost'' (using password: YES等更多相关知识的信息可以在本站进行查询。

本文标签: