Installing MySQL with winforms.NET

I have a C # application that uses MYSQL. I am in beta and need an installation package that includes my application along with MYSQL. So basically I need to install MYSQL and perform a restore from my .NET installation package.

Any help would be greatly appreciated.

+6
c # mysql installation
source share
6 answers

Step 1: you do it wrong

You are trying to install mysql server. This should be your first sign that something is wrong. Most server applications are designed to be installed on servers, not on clients. A noteworthy point in this is that server applications like to assume that they "own" the server. This is a giant no-no application for client applications.

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

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

  • Disconnect MySQL from the client database, such as SQLite or SQL Server Compact Edition.
  • Hack server application installation issues.

I personally would recommend switching to SQLite (or the like) as soon as possible. This is the “right thing” and you won’t need to support hacks for years to come.

Step 3: you still want to hack MySQL because it probably seems easier.

You have been warned. Here are some of the things you need to know and mitigate:

  • MySQL wants to install \ mysql into the program files. If the user has already installed MySQL. You will break everything
    • You need to specify your version of MySQL to install in the user folder. I would recommend it as a subfolder of your application.
  • MySQL wants to run as a service (and the service will most likely be called "mysql"). Again, if the user already has mysql, you will break everything.
    • You will need to start your service under a different name.
  • The MySQL server will most likely want to write files to Program Files \ etc.
    • You will need to change the configuration so that it writes% APPDATA%, etc.
  • MySQL will assume that it is always started by the same user. If you have 2 users on the computer who want to use your program, you will need to hack accordingly, either by starting MySQL as a local account (security flaws) or by installing a separate mysql for each user.

So, with all this in mind, I would say that it is best to configure xcopyable mysql

+4
source share

I am writing an answer to another question

We have taken a different approach. We make MySQL xcopy-capable by calling the shell to create the configuration file before invoking MySQL (to properly configure the base path, etc.). Then we have another service installed using the standard configuration. This service will take care of starting MySQL and another necessary background program (in our case, Apache) for us. Since MySQL is being deployed by us, we wanted to have full control over it.

Thus, with this method, you can simply enable the MySQL package along with your installation and just worry about installing your own service.

+3
source share

This question is very similar to another question . However, the answers to them do not really help.

You can run executables from a custom action in a .Net deployment project , which I would recommend. (Look under the heading "Calling the executable as a user action")

We hope that everyone will take care of this through the command line. If not, try a script installer like Wise or InstallShield, I think they have better support for such things.

Hope this helps!

+2
source share

If you are using or can use NSIS, you should read the following: Silent MySQL Install

Regarding recovery, you can use the script using one of the included utils MySQL or change part of this old NSIS script

Good luck

+2
source share

@Orion Edwards

Thanks so much for the steps. I had a DARK doubt. In fact, we simply turned off SQLite because our stand-alone application needed some procedures and external constraints. But now I feel that SQLite is always the best choice for a standalone desktop application if it is deployed on client machines.

Currently, I have to stick with MySQL. Therefore, I use various types of scripts and mechanisms to handle various possible situations. For example:

  • If the client machine does not have preinstalled mysql, there is a script that completely installs the server and creates the database of users required for my application.
  • If mysql is pre-installed on the client machine, I ask the user to enter the username and password for mysql root and configure the database and users from the application.
  • And thirdly, if for some reason the client machine had a mysql server before, and then was deleted, since mysql WRITS the previous root password even after the removal, I ran mysql server.msi, reset the password (manually transfer, follow some steps) and finally, create an instance of the database, all within the script (of course, these steps should be performed by the USA and not by the user, as this is a very rare case.)

Is this approach OK? Or is there a better, suitable way to do this?

In the future, I think I will stick with SQLite !: -P

+1
source share

Take a look at using the Visual Studio package and deployment tool. It should automatically inject MySQL dependencies if you are connecting from the beginning (MySQL.NET components) and not an ODBC connection. In any case, this allows you to add other software to the installer, which can be automatically unpacked if you need it. I used it to deploy applications in C # using the MySQL libraries that you download from the MySQL site and for third-party MySQL CoreLab libraries.

-one
source share

All Articles