I am in the process of learning MemSQL and as part of this I was trying to execute a procedure from C# client code. The stored procedure exists in the MemSQL database. However, i get the error "Error 1049 has occurred: unknown database 'mysql'". This issue comes only for a procedure, if i execute a simple query from the C# client, it works fine.
I am using MySql.Data.MySqlClient .Net Core Class Library 6.8.8.
Try setting the connection option CheckParameters to false.
The .NET MySQL driver tries to query the mysql
database to get information about the parameters of the stored procedure, and this won't work with MemSQL.
From https://dev.mysql.com/doc/connector-net/en/connector-net-programming-stored.html (archived):
When you call a stored procedure (in versions before the MySQL 8.0 release series), the command object makes an additional SELECT call to determine the parameters of the stored procedure. You must ensure that the user calling the procedure has the SELECT privilege on the mysql.proc table to enable them to verify the parameters. Failure to do this will result in an error when calling the procedure.
This is the default behavior, but it can be changed with a connection option:
From https://dev.mysql.com/doc/connector-net/en/connector-net-6-10-connection-options.html (archived):
CheckParameters , Check Parameters
Default: true
Indicates if stored routine parameters should be checked against the server.
and this option for older versions of the client:
UseProcedureBodies , Use Procedure Bodies , procedure bodies
Default: true
When set to true, the default value, Connector/NET expects the body of the procedure to be viewable. This enables it to determine the parameter types and order. Set the option to false when the user connecting to the database does not have the SELECT privileges for the mysql.proc (stored procedures) table or cannot view INFORMATION_SCHEMA.ROUTINES, and then explicitly set the types of all the parameters before the call and add the parameters to the command in the same order as they appear in the procedure definition.
This option was deprecated in Connector/NET 6.3.7 and removed in Connector/NET 6.10.4; use the Check Parameters option instead.