我在这里看到几个其他帖子的标题相同,并试图按照他们的解决方案但没有帮助..
我正在尝试将unity3d 5连接到在线数据库。但我一直收到这个错误
MySqlException:访问被拒绝用户'altjenb'@'217.73.137.52' (使用密码:YES)MySql.Data.MySqlClient.MySqlStream.ReadPacket()
MySql.Data.MySqlClient.NativeDriver.AuthenticateNew() MySql.Data.MySqlClient.NativeDriver.Authenticate() MySql.Data.MySqlClient.NativeDriver.Open() MySql.Data.MySqlClient.Driver.Open() MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder设置) MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection() MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() UnityEngine.EventSystems.EventSystem:更新()
这是我在C#中的源代码:
MySqlConnection connectionstring = new MySqlConnection("Server=mysql8.db4free.net; Port=3306;Database=testdb;UserId= altjenb; Password = faeefg; ");
string cmdText = "SELECT 1 FROM Login WHERE Username = awd";
using (MySqlCommand SelectCommand = new MySqlCommand(cmdText, connectionstring)) {
MySqlDataReader myReader;
connectionstring.Open();
myReader = SelectCommand.ExecuteReader();
int count = 0;
while (myReader.Read())
{
count = count + 1;
}
if (count == 0)
{
Debug.LogWarning("spunon");
}
else {
Debug.LogWarning("punon");
}
}
为什么我一直这样做?我不明白..
编辑:在收到db4free的推文后,他们建议将端口从3306更改为3307.但仍然出错。KeyNotFoundException:字典中没有给定的键。 System.Collections.Generic.Dictionary`2 [System.String,MySql.Data.MySqlClient.CharacterSet] .get_Item (System.String键)(at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
答案 0 :(得分:0)
尝试从mysql8.db4free.net更改为db4free.net和端口3306.相同的用户详细信息。它应该工作