Reputation: 3867
I am using the ADO.NET data provider MySql.Data.MySqlClient
to access a MySQL database from .NET Core and most things work, but whenever I try to access a stored procedure I see the following exception message:
MySql.Data.MySqlClient.MySqlException : Table 'mysql.proc' doesn't exist
All of the articles I can find recommend running mysql_upgrade
to fix the system tables, but this finds no problems.
And in fact the database does not contain a mysql.proc
table - but it is not supposed to since it is MySQL 8.0!
I've installed the latest version of Connector/NET (8.0.15) using MySQL Installer.
What am I doing wrong?
Upvotes: 3
Views: 15771
Reputation: 21
I stumbled upon this post trying to find a solution to this problem with my Azure-hosted MySQL database, but none of the solutions were applicable. I wanted to share what worked for me (from rfontona's response here):
Azure Database for MySQL – Single Server service, we have a gateway which runs v5.6 which may be cause this error. You can change the port in the connection string to 3309 (default would be 3306), which will connect you to v8.0 client in the gateway. More details here - Supported versions - Azure Database for MySQL | Microsoft Docs
When setting up the MySqlConnectionStringBuilder, I used the following:
new MySqlConnectionStringBuilder {
...
Port = 3309
}
I assume that a similar approach would work within a connection string as well.
Upvotes: 2
Reputation: 5161
As @MikeBeaton explained this is irrelevant version issue. I had faced the same issue when deployed an application which was using mySql.data , and mySql.web dependencies as reference with version 6.0.. , then on deploying a machine that has connector with version 8.0 so it caused this error
CONNECTOR VERSION ON HOSTING MACHINE
BIN FOLDER ASSEMBLY VERSION
SOLUTION
Update your web.config and packages.config files with version from old to new
EXAMPLE
here the old version was 6.9.0 so I updated all with 8.0.21.0
<dependentAssembly>
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.21.0" newVersion="8.0.21.0" />
</dependentAssembly>
likewise find these all dependencies inside this and package file and replace all will solve your problem.
Upvotes: 0
Reputation: 1
I know this post is old, but in case this is question is still relevant... I was able to get around this issue by changing the command type to text instead of a stored procedure and on the command text I used the call command:
sql = "call yourstoreproc()";
cmd = new Mysql.Data.MySqlClient.MySqlCommand(sql, connection);
cmd.CommandType = System.Data.CommandType.Text;
cmd.ExecuteNonQuery();
Upvotes: 0
Reputation: 1
Check out the GetSchema function in ADO.Net in particular the "Procedures" and "Procedure Parameters" collections.
Upvotes: 0
Reputation: 31
If you still face the issue after getting the latest version of MySql.Data package(s), make sure to add CheckParameters=false
Upvotes: 1
Reputation: 3867
The version of Connector/NET installed is... irrelevant!
This is .NET Core, and ADO.NET data providers for .NET Core are obtained via NuGet - so make sure that your .NET Core project is loading the latest version of the MySql.Data
NuGet package.
Older versions of the MySql.Data
NuGet package (pre v.8) do give the above error when trying to access stored procedures on version 8+ MySQL databases.
Upvotes: 3