我正在使用第三方托管服务。
他们为我提供了一个MySQL数据库和一个用户。
我正在运行这个简单的查询
SELECT * FROM db_a4b20a_reales.properties_residental;
当您尝试从MySQL Workbench运行此查询时,我遇到了一些奇怪的情况,但是当我尝试从.Net Core 2.2应用程序运行该查询时,出现以下错误:
SELECT command denied to user 'a4b20a_reales'@'{the server ip...}' for table 'properties_residental'
at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteAsync(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable`1.AsyncEnumerator.BufferlessMoveNext(DbContext _, Boolean buffer, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable`1.AsyncEnumerator.MoveNext(CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.AsyncSelectEnumerable`2.AsyncSelectEnumerator.MoveNext(CancellationToken cancellationToken)
at System.Linq.AsyncEnumerable.SelectEnumerableAsyncIterator`2.MoveNextCore(CancellationToken cancellationToken)
at System.Linq.AsyncEnumerable.AsyncIterator`1.MoveNext(CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext(CancellationToken cancellationToken)
at System.Linq.AsyncEnumerable.Aggregate_[TSource,TAccumulate,TResult](IAsyncEnumerable`1 source, TAccumulate seed, Func`3 accumulator, Func`2 resultSelector, CancellationToken cancellationToken)
at SouthRealEstate.DAL.RealEstateDbServices.GetAllResidentalPropertiesAsync() in C:\omri\work\projects\gitRepo\RealEstateProfessional\SouthRealEstate.DAL\RealEstateDbServices.cs:line 56
server=...;port=3306;user id=a4b20a_reales; password=***; database=db_a4b20a_reales; pooling=true; CharSet=utf8; Allow User Variables=True; Convert Zero Datetime=True; default command timeout=720
MySql.Data.EntityFrameworkCore(8.0.16)
grant permission
,这不是问题。更新:
使用MySql.Data.MySqlClient
时可以正常工作,看来问题出在MySql.Data.EntityFrameworkCore(8.0.16)
连接器上
答案 0 :(得分:0)
在替换为Pomelo.EntityFrameworkCore.MySql
而不是MySql.Data.EntityFrameworkCore(8.0.16)
之后工作。