本文介绍了使用 VB.net 使用 IP 成功连接到 MySQL 时使用 127.0.0.1 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用 127.0.0.1 连接到 MySQL 时,使用 vb.net 我收到以下错误消息:

When trying to connect to MySQL using 127.0.0.1, using vb.net I get the following error message:

使用方法 'mysql_native_password' 为用户 'test' 托管 '127.0.0.1' 的身份验证失败并显示消息:用户 'test'@'localhost' 的访问被拒绝(使用密码:是)"

"Authentication to host '127.0.0.1' for user 'test' using method 'mysql_native_password' failed with message: Access denied for user 'test'@'localhost' (Using Password:YES)"

然而,当我用同一台机器的 IP 地址替换 127.0.0.1 时,连接工作正常.

However when I replace 127.0.0.1 with the IP address for the same machine, the connection works perfectly fine.

那么需要更改什么设置来解决这个问题,以便我可以使用 127.0.0.1?

So what setting need to be changed to solve this issue so that I could use 127.0.0.1?

提前致谢.

推荐答案

每个用户都关联一个 IP,并且只能从这个 IP 连接.可能您的用户test"被允许从IP"连接.并且IP"不一定转换为127.0.0.1",即使它是同一台机器.

Each user is related with an IP, and allowed to connect only from this one. Probably your user 'test' is allowed to connect from the 'IP'. And the 'IP' doesn't necessarily translate to '127.0.0.1', even though it is the same machine.

例如使用 mysql 命令行添加(或与 phpmyadmin 类似):

For example using mysql command line add(or similarly with phpmyadmin):

create user 'test'@'127.0.0.1' identified by 'your_password';

这篇关于使用 VB.net 使用 IP 成功连接到 MySQL 时使用 127.0.0.1 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 19:02