Skip to content

Commit 667d7bb

Browse files
committed
Support MySQL 8.0+
1 parent bb3b9f7 commit 667d7bb

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/Libraries/MySql.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using MySql.Data.MySqlClient;
1+
using MySql.Data.MySqlClient;
22
using Oxide.Core.Database;
33
using Oxide.Core.Libraries;
44
using Oxide.Core.Plugins;
@@ -220,7 +220,13 @@ private void Worker()
220220
[LibraryFunction("OpenDb")]
221221
public Connection OpenDb(string host, int port, string database, string user, string password, Plugin plugin, bool persistent = false)
222222
{
223+
#if NET48 || NETSTANDARD2_0 || NETSTANDARD2_1
224+
// MySQL 8.0+ compatibility for newer target frameworks
225+
return OpenDb($"Server={host};Port={port};Database={database};User={user};Password={password};Pooling=false;default command timeout=120;Allow Zero Datetime=true;SslMode=Disabled;AllowPublicKeyRetrieval=true;CharSet=utf8mb4;", plugin, persistent);
226+
#else
227+
// Older frameworks keep original connection string for backwards compatibility
223228
return OpenDb($"Server={host};Port={port};Database={database};User={user};Password={password};Pooling=false;default command timeout=120;Allow Zero Datetime=true;", plugin, persistent);
229+
#endif
224230
}
225231

226232
public Connection OpenDb(string conStr, Plugin plugin, bool persistent = false)

src/Oxide.MySql.csproj

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,23 @@
1414
<PackageProjectUrl>$(RepositoryUrl)</PackageProjectUrl>
1515
<TargetFrameworks>net35;net40;net45;net46;net48;netstandard2.0;netstandard2.1</TargetFrameworks>
1616
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
17-
<NoWarn>NU1701</NoWarn>
17+
<NoWarn>NU1701;NU5128</NoWarn>
1818
</PropertyGroup>
1919
<ItemGroup>
2020
<PackageReference Include="Oxide.Core" Version="2.0.*" />
21+
<Content Include="Dependencies\*.*" PackagePath="lib\any" />
22+
<None Include="..\resources\icon.png" Pack="true" PackagePath="\" />
23+
</ItemGroup>
24+
<ItemGroup Condition="'$(TargetFramework)' == 'net35'">
2125
<Reference Include="MySql.Data">
2226
<HintPath>Dependencies\MySql.Data.dll</HintPath>
2327
</Reference>
24-
<Content Include="Dependencies\*.*" PackagePath="lib\any" />
25-
<None Include="..\resources\icon.png" Pack="true" PackagePath="\" />
28+
</ItemGroup>
29+
<ItemGroup Condition="'$(TargetFramework)' == 'net40' Or '$(TargetFramework)' == 'net45' Or '$(TargetFramework)' == 'net46'">
30+
<PackageReference Include="MySql.Data" Version="6.9.12" />
31+
</ItemGroup>
32+
<ItemGroup Condition="'$(TargetFramework)' == 'net48' Or '$(TargetFramework)' == 'netstandard2.0' Or '$(TargetFramework)' == 'netstandard2.1'">
33+
<PackageReference Include="MySql.Data" Version="9.5.0" />
2634
</ItemGroup>
2735
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
2836
<Target Name="ChangeAliasesOfStrongNameAssemblies" BeforeTargets="FindReferenceAssembliesForReferences;ResolveReferences">

0 commit comments

Comments
 (0)