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?

Thanks,
Shaun
sdom100Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

http://www.mysql.com/about/legal/licensing/index.html

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sdom100Author Commented:
Thanks.
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 ?

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

sample.sql
========
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`;
 
USE `DBNAME`;
 
DROP TABLE IF EXISTS `test`;
 
CREATE TABLE `test` (
id int,
name varchar(10)
);

Open in new window

0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

sdom100Author Commented:
Thanks
(and apologies for piggybacking the original question)
is MySQL not able to generate this file automatically somehow ?
S.
0
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...
0
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 ?

Thanks,
Shaun
0
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...


0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.