NXDO.Database.Startup
1.0.8
dotnet add package NXDO.Database.Startup --version 1.0.8
NuGet\Install-Package NXDO.Database.Startup -Version 1.0.8
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NXDO.Database.Startup" Version="1.0.8" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NXDO.Database.Startup" Version="1.0.8" />
<PackageReference Include="NXDO.Database.Startup" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NXDO.Database.Startup --version 1.0.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NXDO.Database.Startup, 1.0.8"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NXDO.Database.Startup@1.0.8
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NXDO.Database.Startup&version=1.0.8
#tool nuget:?package=NXDO.Database.Startup&version=1.0.8
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
简述 NXDO.Database.Startup
runtime 执行 MySql/PostgreSql,初始化,启动,建库建表
主要特点
- 组件功能支持 linux
- 环境支持 .NET 6.0,8.0,9.0
- 测试环节,ubuntun 24.04
1. mysql-8.0.11-linux-glibc2.12-x86_64
2. postgresql-17.0.tar.gz(需自行编译源码)
3. postgresql-18.0.tar.gz(需自行编译源码)
环境
- 下载对应的数据库包,解压到目录。例如:d:\ClrSetup\xxdb
- 代码中直接设置该目录即可
- 运行时自动实现:db初始化,db启动...
程序包测试
- linux 测试 ubuntun & mysql8,postgresql17,postgresql18
- window 测试 win7/win10 & mysql8,mysql9,postgresql17
- 翰高(早期windows版,技术支持有求必应,国产化Db平替首先)
- 金仓(V1.0.6 + 加入了测试,基本能用,细节未处理)
代码示例
- postgre 示例
var pg = DbStart.Create<PostgreSql>(@"d:\ClrSetup\pgsql");
pg.CopyLibraryDlls(); //linux下软链接(运行在windows下时不处理)
pg.DbServer.Password = "123";
pg.DbServer.Port = 5566;
pg.DbServer.CreateDatabaseName = "testdb";
pg.DbFolder.CreateSqlFile = "v.sql";
if (pg.IsSetup) {
pg.DbServer.CreateDatabaseName = "";
pg.DbFolder.CreateSqlFile = "";
}
pg.AddFirewallPort(pg.DbServer.Port); //windows防火墙
pg.DbServer.AccessMode = DbAccessMode.Remote; //远程访问
var success = !pg.IsSetup ? pg.Setup() : pg.Start();
- mysql 示例
var my = DbStart.Create<MySql>(@"d:\ClrSetup\mysql");
my.CopyLibraryDlls(); //linux下软链接(运行在windows下时不处理)
my.DbServer.Password = "123";
my.DbServer.Port = 3838;
my.AddFirewallPort(my.DbServer.Port); //windows防火墙
my.DbServer.AccessMode = DbAccessMode.Remote; //远程访问
//d:\ClrSetup\mysql\v.sql
my.DbFolder.CreateSqlFile = "v.sql";
var success = !my.IsSetup ? my.Setup() : my.Start();
- 连续启动(或 - 初始化安装)及关闭
var db = DbStart.Create<MySql>(@"d:\ClrSetup\mysql"); //或者使用PostgreSql
db.CopyLibraryDlls(); //linux下软链接(运行在windows下时不处理)
//第一个db服务
db.DbServer.Password = "123";
db.DbServer.Port = 3306; //默认端口
//db.DbFolder.Data = "data"; //默认数据目录(默认可以不赋值)
db.Start(); //如果已经初始化,此处也可以初始化安装
//第二个db服务
db.DbServer.Password = "456";
db.DbServer.Port = 3308; //3308端口
//db.DbFolder.Data = "data2"; //第二个数据目录(如果是初始化,请赋值指定目录)
db.Start(); //如果已经初始化,此处也可以初始化安装
//此时有3306与3308两个服务
db.Stop(3306); //关闭3306的服务
//db.Stop(); //关闭全部服务(3306与3308)
应用场景
- 业务系统启动,随后Db自启
- 单台 m 机上 j 使用,自启停,结束导回数据。
- 开发人员对db初始化,启动,不熟悉,直接嵌入自己的应用或者学习db使用。
修复与新功能
- V1.0.1 - ubuntun 24.04 调整 mysql8,执行程序自动chmod,支持so文件链接,进程输出监视优化
- V1.0.2 - 远程访问属性设置,处理防火墙特定端口(win),修正信息输出光标位,信息带begin/end提示,内测的bug修复
- V1.0.3 - 新增进程存在判断方法,如果linux启动(同一端口、同一data目录)多个时优雅的停止错误进程,优化调整防火墙(win),新增iptables防火墙(linux),关闭支持port参数。
- V1.0.4 - 调整linux下pg,pg自动配置调优(win & linux),调整输出信息(不关心成功与失败时)前缀为 over,调整mysql信息输出的时间戳.
- V1.0.5 - 自编译pg17(ubuntun),提示缺库信息,可后续手动建so的软链,其它优化的调整,内测的bug修复.
- V1.0.6 - 预留处理 arm64 环境支持,解决linux(pg)对自身库的依赖,pg提示缺库信息输出的功能被移除,sql文件不存在时由抛出异常改为控制台警告输出.
- V1.0.7 - 自编译pg18(ubuntun),调整so软链接: CopyLibraryDlls() 方法。官方后续出pg19版本,如还是现有的那些so文件亦可支持。理论上支持17之前的版本(未测试)。
- V1.0.8 - DbStart(实例).StopAutoCallOnApplicationExit 属性,应用退出时自动关闭db(属性默认:true), iptables防火墙(linux)调整。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
StopAutoCallOnApplicationExit 属性,应用退出时自动关闭db(属性默认:true), iptables防火墙(linux)调整。