数据库连接在本地有效,但在发布到服务器时失败 [英] Database connection works locally but fails when published to server

查看:58
本文介绍了数据库连接在本地有效,但在发布到服务器时失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在ASP.net网站上工作,所有工作都在进行中,我想将其部署到goDaddy的服务器上以测试我所做的更改.我有这段代码,完全相同的项目,具有相同的数据库连接字符串,并且以前在服务器上调用过.真的没什么改变,我只是改变了与数据库完全无关的类中的一个方法.我将代码信任设置为完全,因此代码应具有连接权限.当我将代码信任度设置为较低时再将其设置为满",这会给我一个错误,提示我我没有所需的权限,因此我确定这不是问题所在.

I'm currently working on a ASP.net website, I have everything working and wanted to deploy it to the server which is goDaddy to test the changes I made. I have had this code, the exact same project with the identical database connection string and calls on the server before. Nothing changed really I just changed one method in a class which has nothing to do with the database at all. I have the code trust set to full so the code should have permission to connect. When I set the code trust lower then full it will give me an error that I don't have the needed permissions so I'm sure this isn't where the problem lays.

就像标题所述,当我在本地环境中尝试代码时,一切都很好.当我尝试在服务器上执行相同的操作时,我收到一条消息,提示:

Like the title says when I try the code on my local environement everything works just fine. When I try to do the same thing on the server I get a message saying:

无法连接到任何指定的MySQL主机"当您转到 http://test.ceremoniecompleet.nl/admin 并尝试登录时,您将获得错误.当我尝试在本地登录时,效果很好.

"unable to connect to any of the specified MySQL hosts" when you go to http://test.ceremoniecompleet.nl/admin and try to log in you will get the error. When I try to login locally it works just fine.

我正在使用的连接字符串如下

The connection string I'm using is as follows

con.ConnectionString = "server=188.121.44.188; database=CeremonieCompleet_DB; uid=CCU; pwd=mypassword;";

我尝试使用 188.121.44.188:3306 ,但这根本不起作用.一位支持者建议使用此功能,但这在本地和服务器上均会失败.

I've tried to use 188.121.44.188:3306 but this doesn't work at all. One of the godaddy support people suggested using this but this just fails on both locally and the server.

有人知道会发生什么吗?唯一真正改变的是我以前使用过Visual Studio 2012,现在我正在使用Visual Studio 2015,因为我的电脑需要全新安装.

does anyone have any clue what could be going on? the only thing that changed really is that I used visual studio 2012 before and now I'm using visual studio 2015 because my pc needed a completely fresh install.

当前我添加到项目中的mysql.data.dll版本为6.0.3.0,可能只是需要升级吗?

Currently the mysql.data.dll that I added to the project is version 6.0.3.0 could it be that this just needs an upgrade?

推荐答案

188.121.44.188是Godaddy服务器吗?
如果是,请尝试更改为"localhost".
如果不是,请尝试在Godaddy中创建数据库并将服务器设置为"localhost".

要设置端口,您需要此字符串"server =<>; port = 3306; ..."

The 188.121.44.188 is the godaddy server?
If it is, try changing to 'localhost'.
If it isn't, try to create a database in godaddy and set the server to 'localhost'.

To set the port, you need this string "server=<>; port=3306; ..."

这篇关于数据库连接在本地有效,但在发布到服务器时失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆