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

0

For some reason After a windows 10 upgrade resulting to a bsod event, I had to do a fresh install of my PC. I have visual studio 2017 and MySQL set up for my C# ASP.NET EF projects. I have installed MySQL similar to my old system and I have a laptop with similar setup which works okay.

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.

  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.

I have maintained using localhost as string and changed to the IP still cannot connect on debug.

c#
mysql
asp.net-mvc
visual-studio
entity-framework
asked on Stack Overflow Oct 6, 2018 by Diin

1 Answer

0

On the menu bar, choose View, Other Windows, Data Sources (or choose the Shift+Alt+D keys).

In the Choose Data Source window select MySql Database and press Continue.

in the Add Connection window, set server name: 127.0.0.1 or localhost.

Then test again using the debug to ensure it's now fixed.


User contributions licensed under CC BY-SA 3.0