Creating DB on Install

Posted on 2008-11-16
Last Modified: 2013-11-27
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?

Question by:sdom100
    LVL 26

    Accepted Solution

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


    Author Comment

    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 ?

    LVL 26

    Expert Comment

    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`;
    CREATE TABLE `test` (
    id int,
    name varchar(10)

    Open in new window


    Author Comment

    (and apologies for piggybacking the original question)
    is MySQL not able to generate this file automatically somehow ?
    LVL 26

    Expert Comment

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

    Author Comment

    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 ?

    LVL 26

    Expert Comment

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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
    Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now