• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

Creating DB on Install

My application (C# developed in VS2005) requires a MySQL database.
What is the best way to go about deploying the MySQL engine to my client's machines

AND THEN install my database schema ready for use by the application?

  • 4
  • 3
1 Solution
UmeshMySQL Principle Technical Support EngineerCommented:
Best way to deploy MySQL on clients machine is -

First install MySQL on client machine and create your DB on it (I assume you have a SQL file which does DB+schema creation stuff)

- Get a Stable copy MySQL from MySQL
    - http://dev.mysql.com/downloads/mysql/5.0.html#downloads
    - Look for something - "Without installer (unzip in C:\)"

This should be done at client side

- Unzip in C:/ or D:/  or E:/
 MySQLcan be started in two ways.. manually or by making it as to run as service

    How to Start MySQL
    - Starting MySQL
       - cd c:/mysql/bin
       - mysqld-nt --install            (this will install mysql service)
       - net start mysql                 (start mysql)

   (Pls avoid this way)
    How to Start Manually
    - Starting MySQL
       - cd c:/mysql/bin
       - mysql-nt --defaults-file=../my-small.ini

MySQL installation is done... No you need to deploy your DB on it...  I assume that you have createDBSchema.sql file, which creates DB, then tables..

cd to C:/mysql/bin
mysql -uroot -p < createDBSchema.sql

That's it... I have given you the commands to start on.. you can do it manually or automatically thru your c#

Lastly, don't forget to read MySQL's licensing policy


sdom100Author Commented:
I have fallen at the first hurdle - cant create the SQL script in MySQL
This surely must be easy - it's a piece of cake in SQL Server !
How do i create the 'create' SQL for my chosen DB ?

UmeshMySQL Principle Technical Support EngineerCommented:
Your SQL script should be something like this..

Im showing how the sql script should be.. pls place your actual schema in the file and make sure file has .sql extension..

create database if not exists `DBNAME`;
id int,
name varchar(10)

Open in new window

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

sdom100Author Commented:
(and apologies for piggybacking the original question)
is MySQL not able to generate this file automatically somehow ?
UmeshMySQL Principle Technical Support EngineerCommented:
Which files are you talking about.. once you install MySQL it creates required DB (MySQL,Information_schema),  one sample DB called "test"...

BTW, how come MySQL will create this file? I have given you samle sql script thru which you can create and populate you DB...
sdom100Author Commented:
I have created a database [myDatabase] This contains 30 tables.
This db is working fine and I have a .NET application that happily uses it

What i need to do is to recreate that schema on my client's machines once they have installed the DB engine.
Your post tells me how to do that using a create script but I do not want to have to manually write that out to create all my tables.

Is there a way to get MySQL to automatically write me a SQL create script like the one in your example ?

UmeshMySQL Principle Technical Support EngineerCommented:
Ok.. cool

>I have created a database [myDatabase] This contains 30 tables.

On the machine where you have created DB... cd to mysql/bin directory

mysqldump --opt -userUserName -pSecret DBNAME > myDatabase.sql

Pls change username password details in above command....  Once you ran above command you will have the dump of your DB...


Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now