简体   繁体   English

调试时Visual Studio 2017尝试使用IP连接到本地Mysql

[英]Visual Studio 2017 tries to connect to Local Mysql with an IP when debugging

For some reason After a windows 10 upgrade resulting to a bsod event, I had to do a fresh install of my PC. 由于某种原因,在Windows 10升级导致bsod事件后,我不得不重新安装PC。 I have visual studio 2017 and MySQL set up for my C# ASP.NET EF projects. 我为C#ASP.NET EF项目设置了Visual Studio 2017和MySQL。 I have installed MySQL similar to my old system and I have a laptop with similar setup which works okay. 我已经安装了类似于旧系统的MySQL,并且有一台笔记本电脑具有类似的设置,可以正常工作。

The problem is when I try to debug the application tries to connect to the local mysql(version 5.7.23) using an IP instead of localhost and fails to authenticate. 问题是,当我尝试调试应用程序时,尝试使用IP而非本地主机连接到本地mysql(版本5.7.23),并且无法通过身份验证。

  MySql.Data.MySqlClient.MySqlException HResult= 0x80004005 
 Message=Authentication to host '' for user '' using method 
`'mysql_native_password' failed with message: Access denied for user ''@'xxx.xxx.x.x' 
(using password: NO) Source=MySql.Data'`

When I run update-database etc in the console of visual studio it connects to database alright and update tables etc. But it fails to connect when I debug the application. 当我在Visual Studio的控制台中运行update-database等时,它可以连接到数据库并更新表等。但是在调试应用程序时它无法连接。

I have maintained using localhost as string and changed to the IP still cannot connect on debug. 我一直使用本地主机作为字符串并更改为IP仍无法在调试时连接。

On the menu bar, choose View, Other Windows, Data Sources (or choose the Shift+Alt+D keys). 在菜单栏上,选择“视图”,“其他Windows”,“数据源”(或选择Shift + Alt + D键)。

In the Choose Data Source window select MySql Database and press Continue. 在“选择数据源”窗口中,选择“ MySql数据库”,然后按“继续”。

in the Add Connection window, set server name: 127.0.0.1 or localhost. 在“添加连接”窗口中,设置服务器名称:127.0.0.1或localhost。

Then test again using the debug to ensure it's now fixed. 然后使用调试再次测试以确保现在已修复。

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

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