[英]MYSQL installation with a .NET winforms app
I have a C# application that's utilizes MYSQL. 我有一个利用MYSQL的C#应用程序。 I'm at a beta release point and need an installation package that includes my application, along with MYSQL.
我正处于测试版发布点,需要一个包含我的应用程序的安装包,以及MYSQL。 So basically, I need to install MYSQL and perform a restore from within my .NET install package.
所以基本上,我需要安装MYSQL并从我的.NET安装包中执行恢复。
Any help would be greatly appreciated. 任何帮助将不胜感激。
You're attempting to install the mysql server . 您正在尝试安装mysql 服务器 。 This should be your first clue that something is wrong.
这应该是你第一个发现错误的线索。 Most server apps are designed to be installed on servers, not on clients.
大多数服务器应用程序都设计为安装在服务器上,而不是客户端上。 The notable point in this is that server apps like to assume that they 'own' the server.
值得注意的是,服务器应用程序喜欢假设他们拥有“服务器”。 This is a giant no-no for client apps.
对于客户端应用程序来说,这是一个巨大的禁忌。
Now that we've established that we're doing it wrong, we need to choose what to do. 现在我们已经确定我们做错了,我们需要选择做什么。 We have 2 options:
我们有两个选择:
I personally would recommend switching to SQLite (or similar) as soon as possible. 我个人会建议尽快切换到SQLite(或类似)。 It's the "right thing" to do, and you won't have to be maintaining hacks for years to come.
这是“正确的事情”,你不必在未来几年内维持黑客行为。
You have been warned. 你被警告了。 Here are some of the things you will need to be aware of, and mitigate:
以下是您需要注意和缓解的一些事项:
So with all this in mind, I'd say your best bet is to set up an xcopyable mysql 所以考虑到这一点,我想说你最好的办法是设置一个xcopyable mysql
I've post the answer on another question 我在另一个问题上发布了答案
We took a different approach on this.
我们对此采取了不同的方法。 We make MySQL xcopy-able, by writting a wrapper to generate the configuration file before calling MySQL (to correctly setup the base path and so on).
我们通过在调用MySQL之前编写包装器来生成配置文件(以正确设置基本路径等)来使MySQL xcopy-able成为可能。 Then we have another service installed using the standard setup.
然后我们使用标准设置安装了另一个服务。 This service will take care of starting MySQL and other required background program (in our case Apache) for us.
这项服务将负责为我们启动MySQL和其他所需的后台程序(在我们的例子中为Apache)。 Since the MySQL is deploy by us, we wanted to have full control over it.
由于MySQL由我们部署,我们希望完全控制它。
So with this method, you could simply include the MySQL package along with your installation, and just worried about installing your own service. 因此,使用此方法,您可以简单地包含MySQL软件包以及您的安装,并且只是担心安装自己的服务。
This question is very similar to another question . 这个问题与另一个问题非常相似。 However, the answers don't really help.
但是,答案并没有真正帮助。
You can run executables from a custom action in the .Net deployment project , that's what I'd recommend. 您可以从.Net部署项目中的自定义操作运行可执行文件 ,这就是我建议的。 (Look under the heading "Calling an executable as a custom action")
(请在“将可执行文件作为自定义操作调用”标题下查找)
Hopefully everything can be taken care of by via the command line. 希望通过命令行可以处理所有事情。 If not, try a scripted installer like Wise or InstallShield, I think they have better support for stuff like this.
如果没有,尝试像Wise或InstallShield这样的脚本安装程序,我认为他们可以更好地支持这样的东西。
Hope that helps! 希望有所帮助!
If you're using, or can use, NSIS, you should read this: Silent MySQL Install 如果您正在使用或可以使用NSIS,您应该阅读: 无声MySQL安装
Regarding the restore, you might be able to script something up using one of MySQL's included utils or modify part of this old NSIS script 关于还原,您可以使用MySQL包含的utils之一编写脚本或修改此旧NSIS脚本的一部分
Good luck! 祝好运!
@Orion Edwards @Orion Edwards
Thanks a lot for the steps. 非常感谢您的步骤。 I was having the SAME doubt.
我对SAME有疑问。 In fact, We just turned SQLite down because our standalone application needed some procedures and foreign key contraints.But now I feel SQLite is always a better choice for standalone desktop application if it is do be deployed on client machines.
事实上,我们刚刚拒绝了SQLite,因为我们的独立应用程序需要一些程序和外键约束。但是现在我觉得如果将SQLite部署在客户机上,SQLite总是更好的选择。
For now,I have to stick to MySQL. 现在,我必须坚持使用MySQL。 So I'm using different kinds of scripts and mechanisms to handle different possible situations.
所以我使用不同类型的脚本和机制来处理不同的可能情况。 Eg:
例如:
Is this approach OK? 这种方法可以吗? Or there is a better,appropriate way to do this?
或者有更好,更合适的方法来做到这一点?
In future I think i'll stick to SQLite ! 将来我想我会坚持SQLite ! :-p
:-P
Have a look at using Visual Studio's package and deployment tool. 看看使用Visual Studio的包和部署工具。 It should automatically bring in the MySQL dependencies if you connect natively (MySQL .NET components) rather than an ODBC connection.
如果您本地连接(MySQL .NET组件)而不是ODBC连接,它应该自动引入MySQL依赖项。 In any case it allows you to add other software to an installation program that can be automatically unpacked if you need it.
在任何情况下,它都允许您将其他软件添加到安装程序中,如果需要,可以自动解压缩。 I have used it to deploy C# apps using the MySQL libraries that you download from MySQL website and for CoreLab's MySQL 3rd party libraries.
我使用它来使用从MySQL网站下载的MySQL库和CoreLab的MySQL第三方库来部署C#应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.