Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
451 views
in Technique[技术] by (71.8m points)

c# - MYSQL installation with a .NET winforms app

I have a C# application that's utilizes MYSQL. I'm at a beta release point and need an installation package that includes my application, along with MYSQL. So basically, I need to install MYSQL and perform a restore from within my .NET install package.

Any help would be greatly appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Step 1: You're doing it wrong

You're attempting to install the mysql server. 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.

Step 2: Make a decision, now that we are properly informed

Now that we've established that we're doing it wrong, we need to choose what to do. We have 2 options:

  1. Switch away from MySQL to a 'client' database such as SQLite or SQL Server Compact Edition.
  2. Hack around the problems of installing the server app.

I personally would recommend switching to SQLite (or similar) as soon as possible. It's the "right thing" to do, and you won't have to be maintaining hacks for years to come.

Step 3: You'll want to hack MySQL anyway because it probably seems easier.

You have been warned. Here are some of the things you will need to be aware of, and mitigate:

  1. MySQL wants to install into program filesmysql. If the user already has MySQL installed themselves. You'll break everything
    • You'll need to tell your version of MySQL to install into a custom folder. I'd recommend it as a subfolder of your application
  2. MySQL wants to run as a service (and the service will likely be called 'mysql'). Again if the user already has mysql, you'll break everything.
    • You'll need to run your service under a different name
  3. The MySQL server will likely want to write files to Program Filesetc.
    • You'll need to change it's configuration so it writes to %APPDATA% and so on
  4. MySQL will assume it is always being run by the same user. If you have 2 users on the machine who want to use your program, you'll need to hack accordingly, by either running MySQL as a local service account (security flaws ahoy), or by installing a seperate mysql for each user.

So with all this in mind, I'd say your best bet is to set up an xcopyable mysql


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...