[英]Remote server claims table doesn't exist
I have a connection string in my config files like so我的配置文件中有一个连接字符串,就像这样
add name="entities" connectionString="Data Source=localhost;user id=username;password=somepassword;persist security info=True;database=dbname" providerName="MySql.Data.MySqlClient" add name="entities" connectionString="Data Source=localhost;user id=username;password=somepassword;persist security info=True;database=dbname" providerName="MySql.Data.MySqlClient"
This works with localhost.这适用于本地主机。
As soon as I change the Data Source to Data Source=123.34.45.56 <-- some remote server一旦我将数据源更改为 Data Source=123.34.45.56 <-- 一些远程服务器
I get MySql.Data.MySqlClient.MySqlException: Table 'mydb.Emails'
doesn't exist我得到MySql.Data.MySqlClient.MySqlException: Table 'mydb.Emails'
不存在
If I use connection code in c# it will work against the remote server : Example below如果我在 c# 中使用连接代码,它将对远程服务器起作用:下面的示例
MySql.Data.MySqlClient.MySqlConnection mySqlConnection = new
MySql.Data.MySqlClient.MySqlConnection();
mySqlConnection.ConnectionString = "Data Source=123.34.45.56;user id=username;password=somepassword;persist security info=True;database=dbname";
string conString = mySqlConnection.ConnectionString;
using (MySqlConnection connection = new MySqlConnection(conString)) {
connection.Open();
using (MySqlCommand command = new MySqlCommand(
"SELECT * FROM emails",
connection)) {
using (MySqlDataReader reader = command.ExecuteReader()) {
while (reader.Read()) {
for (int i = 0; i < reader.FieldCount; i++) {
var tr = reader.GetValue(i);
}
}
}
}
}
How come the connection string in the web.config is throwing this error for every table MySql.Data.MySqlClient.MySqlException: Table 'mydb.Emails'
doesn't exist.为什么 web.config 中的连接字符串会为每个表MySql.Data.MySqlClient.MySqlException: Table 'mydb.Emails'
抛出此错误MySql.Data.MySqlClient.MySqlException: Table 'mydb.Emails'
不存在。
The tables are there as the c# connection code can open a connection and query the data just fine.表在那里,因为 c# 连接代码可以打开连接并查询数据就好了。
How do I get the connection string to work?如何让连接字符串工作?
John Garrard was correct.约翰·加勒德是对的。 It was a case sensitivity issue with the database located on two different operating systems.这是位于两个不同操作系统上的数据库的区分大小写问题。 I needed to make my entities case sensitive and the switching the connection string will work between the Windows development machine and the Linux production machine.我需要让我的实体区分大小写,并且连接字符串的切换将在 Windows 开发机器和 Linux 生产机器之间工作。 Thanks.谢谢。
I came across this issue when moving from a Windows dev to AWS test system.从 Windows 开发人员迁移到 AWS 测试系统时,我遇到了这个问题。 There is a parameter called "lower_case_table_names" that controls how MySql matches table names which defaults to 0 on linux and 1 in Windows (meaning case sensitive and insensitive):有一个名为“lower_case_table_names”的参数,用于控制 MySql 如何匹配表名,该表名在 linux 上默认为 0,在 Windows 中默认为 1(意味着区分大小写和不区分大小写):
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.