views:

943

answers:

6

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.

+1  A: 

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. (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.

Hope that helps!

Zachary Yates
+1  A: 

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). 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. Since the MySQL is deploy by us, we wanted to have full control over it.

So with this method, you could simply include the MySQL package along with your installation, and just worried about installing your own service.

faulty
A: 

Have a look at using Visual Studio's package and deployment tool. It should automatically bring in the MySQL dependencies if you connect natively (MySQL .NET components) rather than an ODBC connection. 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.

Philluminati
This would work well for installing the client libraries, and I suspect is already being done. The issue is trying to install the mysql *server*
Orion Edwards
A: 

If you're using, or can use, NSIS, you should read this: Silent MySQL Install

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

Good luck!

hb
A: 

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 files\mysql. 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 Files\etc.
    • 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

Orion Edwards
A: 

@Orion Edwards

Thanks a lot for the steps. I was having the SAME doubt. 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.

For now,I have to stick to MySQL. So I'm using different kinds of scripts and mechanisms to handle different possible situations. Eg:

  • If the client machine has no mysql pre-installed, there is a script which completely installs the server and creates the database, users required for my application.
  • If mysql is pre-installed on client machine, I'm asking user for mysql's root username and password and setting up the database & users from within the apllication.
  • And thirdly, if for some reason client machine had mysql server earlier and then it was uninstalled, since mysql DOES keep track of previous root password even after uninstalling,I run mysql server's .msi, reset the password (manually carry out some steps), and finally create instance of database, all within a script (of course these steps are needed to be carried out by US, not the user as this is a very rare case.)

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

In future I think i'll stick to SQLite! :-p

Nikhil Patil