简体   繁体   English

用户的MySql访问被拒绝-无法创建该软件正在寻找的用户

[英]MySql access denied for user - can't create the user the software is looking for

My connection string looks like this: 我的连接字符串如下所示:

string server = "localhost";
string database = "stman";
string user = "logan";
string pass = "root";

string connStr = String.Format("Data Source={0};Initial Catalog={1}; User Id={2}; Password={3};", server, database, user, pass);

Given my understanding, this means MySql should be using 'logan'@'localhost' for the login, but it isn't. 根据我的理解,这意味着MySql应该使用'logan'@'localhost'进行登录,但事实并非如此。

It looks as though it's using 'logan'@<server's fully qualified name> : 似乎正在使用'logan'@<server's fully qualified name>

Access denied for user 'logan'@'HP-PL-ML110.young.home' 用户'logan'@'HP-PL-ML110.young.home'的访问被拒绝

I'm at a loss right now. 我现在很茫然。 SqlYog doesn't allow me to create a user with that hostname, my options for hostname are % , localhost or 127.0.0.1 SqlYog不允许我使用该主机名创建用户,我的主机名选项为localhost127.0.0.1

Can anyone help me make sure that the website is using the specified username here? 谁能帮助我确保网站在此处使用指定的用户名? I have no idea what to look at to fix this 我不知道该怎么解决

Joe's comment: 乔的评论:

Have you tried disabling host name lookup, as in this question 您是否尝试过禁用主机名查找,如以下问题所示

Applying this didn't fix the issue but it did change the settings so that I could use the IP address in the connection string. 应用此方法不能解决问题,但确实可以更改设置,以便可以在连接字符串中使用IP地址。

This does mean I had to create a new user (I found that, in Sqlyog, you can enter something different in the hostname field in user creation) and grant the new user the required permissions on the target database. 这确实意味着我必须创建一个新用户(我发现,在Sqlyog中,您可以在用户创建时的主机名字段中输入其他内容),并向新用户授予目标数据库所需的权限。

It's not exactly a solution, but it is a viable workaround that's got me back to a point where I can actually progress further in my development now. 这不是完全解决方案,但这是一个可行的解决方法,使我回到了现在可以真正进一步发展的地步。

Thanks Joe 谢谢

string connStr = String.Format("Data Source={0};Initial Catalog={1}; User Id={2}; Password={4};", server, database, user, pass);

应该

string connStr = String.Format("Server={0};Database={1};Uid={2};Pwd={4};", server, database, user, pass);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM