This entry provides instructions for “silently” installing MySQL on a Microsoft Windows server. I use the term “silent install” to describe the method of passing parameters to the Microsoft Installation Package (MSI) to bypass installation screens. This allows you to deploy MySQL with your application and to install MySQL without end-user intervention. The developer can define the install location, the appropriate storage engines, the root password and the server configuration.
Most application developers use some sort of software for creating an application installer. Common tools include Install Shield, Wise Installation, InstallBuilder and Windows Installer. These installation software tools can also be used to install MySQL by launching the MySQL MSI and the MySQL Instance configuration utility ( MySQLInstanceConfig.exe ) from the command-line.
To get started, download the Windows Essentials from http://dev.mysql.com/downloads.
Then, look for an option in your installation tool to execute the following:
C:\>msiexec /q /log install.txt /i mysql-advanced-5.1.32-win32.msi datadir=”c:\installs\myapp” installdir=”c:\installs\myapp”
The MSI installer will add MySQL to the start menu, add registry values and add MySQL to the add/remove programs option from the control panel.
To configure the server, prepare the my.ini, set the root password and start the service, you’ll need to execute the following:
C:\>MySQLInstanceConfig.exe -i -q “-lC:\mysql_install_log.txt” “-nMySQL Server 5.1.234” -pC:\installs\myapp” -v5.1.234 “tc:\installs\myapp\my-small.ini” “-cC:\mytest.ini ServerType=DEVELOPMENT DatabaseType=MIXED ConnectionUsage=DSS Port=3311 ServiceName=MySQLCust RootPassword=1234
This installation method has the benefit of adding MySQL to the control panel and the startup menus. It also installs the default mysql tables. The only remaining task is to import your application tables into MySQL by running mysqldump ( http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html ) on your development server and then loading the dump files into the target server.
In a future blog entry, I’ll discuss launching the mysqld.exe directly without actually installing MySQL.
Really useful – I await the next part with keen interest.
Comment by David Goadby — November 12, 2009 @ 4:03 pm |
Thanks
Comment by Anonymous — December 18, 2009 @ 4:57 pm |
Thanks Babu
Comment by Raju — December 22, 2009 @ 4:56 pm |
Hi,
How can I use character set with MySQLInstanceConfig.exe (paramaters)
thanks
Comment by agit — May 19, 2010 @ 7:57 am |
it helps a lot
Comment by Anonymous — August 2, 2010 @ 1:47 am |
hi i am using mysql server 5.1.51. i followed your code to configure mysql server. but it is not configured. it shows error like below:
could not open require default file: C:\Program Files\MySQL\MySQL Server 5.1\my.ini.
fatal error in default handling. program aborted.
i am using the code
MySQLInstanceConfig.exe -i -q “-lC:\mysql_install_log.txt” “-nMySQL Server 5.1″ “-pC:\Program Files\MySQL\MySQL Server 5.1″ -v5.1.51 “-tC:\Program Files\MySQL\MySQL Server 5.1\my-template.ini” “-cC:\mytest.ini” ServerType=DEVELOPMENT DatabaseType=MIXED ConnectionUsage=DSS Port=3306 ServiceName=MYSQL RootPassword=pass
help me
thanks in advance
Comment by prabhu — October 5, 2010 @ 6:57 am |
Did the my.ini file get created in c:\program files\mysql\mysql server 5.1\ ? Check that the file exists and verify that the permissions are read/write. Also, see if there are any errors logged in c:\mysql_install_log.txt
Comment by Lee Stigile — October 5, 2010 @ 2:10 pm |
I didn’t get my.ini in c:\program files\mysql\mysql server 5.1\
there is no error in log file and it contains the following
—————————————-
Welcome to the MySQL Server Instance Configuration Wizard 1.0.17.0
Date: 2010-10-06 10:48:38
Installing service …
Product Name: MySQL Server 5.1
Version: 5.1.51
Installation Path: C:\Program Files\MySQL\MySQL Server 5.1\
Creating configuration file C:\Program Files\MySQL\MySQL Server 5.1\mytest.ini using template C:\Program Files\MySQL\MySQL Server 5.1\my-template.ini.
Options:
DEVELOPMENT
MIXED
DSS
STRICTMODE
Variables:
port: 3306
default-character-set: latin1
basedir: “C:/Program Files/MySQL/MySQL Server 5.1/”
datadir: “C:/Program Files/MySQL/MySQL Server 5.1/Data/”
Creating Windows service entry.
Service name: “MySQL”
Parameters: “C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld” –defaults-file=”C:\Program Files\MySQL\MySQL Server 5.1\mytest.ini” MySQL.
Windows service MySQL installed.
Comment by prabhu — October 6, 2010 @ 5:20 am |
I apologize for the delay. Please check the parameter: “-tC:\Program Files\MySQL\MySQL Server 5.1\my-template.ini”
It sounds like the my.ini file is not getting created. The -t parameter takes a sample config file, which you have created; and uses that for the my.ini. Is there a my-template.ini in the directory specified? In my example, I use the my-small.ini, which is included with the install.
Comment by Lee Stigile — October 7, 2010 @ 9:08 pm |
Hi ,
when i gave command for MYSQLInstance config wizard with all the required parameters, it is getting stuck in between,not sure why this is happening,when i try to do it manually by running exe file of wizard it works fine,
There are not errors in the log file too…
Here is the command which i used…
“C:\Program Files\MYSQL\MySQL Server 5.5\bin\MySQLInstanceConfig.exe” -i “-lC:\Program Files\MySQL\MySQL Server 5.5\mysql-instance-wizard-log.txt” “-nMySQL Server 5.5″ “-pC:\Program Files\MySQL\MySQL Server 5.5\” -v5.5.1 “tC:\Program Files\MySQL\MySQL Server 5.5\my-template.ini” “-cC:\Program Files\MySQL\MySQL Server 5.5\mynbm.ini” ServerType=DEVELOPMENT RootPassword=babu AddBinToPath=yes
i tried giving (RootCurrentPassword=babu) along with this , to test whther this is causing the problem, but no clue..
the log file shows the following
Welcome to the MySQL Server Instance Configuration Wizard 1.0.16.0
Date: 2011-05-12 12:24:45
Installing service …
Product Name: MySQL Server 5.5
Version: 5.5.1
Installation Path: C:\Program Files\MySQL\MySQL Server 5.5\
Creating configuration file C:\Program Files\MySQL\MySQL Server 5.5\mynbm.ini using template C:\Program Files\MySQL\MySQL Server 5.5\my-template.ini.
Options:
DEVELOPMENT
MIXED
DSS
STRICTMODE
Variables:
port: 3306
default-character-set: latin1
basedir: “C:/Program Files/MySQL/MySQL Server 5.5/”
datadir: “C:/Program Files/MySQL/MySQL Server 5.5/Data/”
Creating Windows service entry.
Service name: “MySQL”
Parameters: “C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqld” –defaults-file=”C:\Program Files\MySQL\MySQL Server 5.5\mynbm.ini” MySQL.
Windows service MySQL installed.
Any help is appreciated….
Thanks in Advance
Suresh
Comment by Suresh babu — May 12, 2011 @ 7:04 am |
Unless something just changed in my XP environment, it seems as though the 5.5 installer doesn’t allow double-quotes. I removed quotes. I used a forward slash (/) to denote spaces. Here’s an example of a successful install.
C:\installs\myapp\bin>MySQLInstanceConfig.exe -i -q -lC:\aa.txt -nMySQL/ Server/ 5/.1/.234 -pC:\installs\myapp -v5.1.
-tc:\installs\myapp\my-small.ini -cC:\mytest.ini ServerType=DEVELOPMENT DatabaseType=MIXED ConnectionUsage=DSS Port
11 ServiceName=MySQLCust3 RootPassword=1234
Comment by lstigile — May 13, 2011 @ 10:28 pm |
hi, i am KS Lim from malaysia.
I have created an application, now I want to deploy the application by using installshield 2010 together with MySQL database 5.1.45
I have created the bat file as follow :
==================================================================================
echo off
cls
echo Starting Install …
set mysql_msi=”mysql-5.1.45-win32.msi”
set mysql_svname=MySQL
set mysql_datadir=”C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.1\data”
set mysql_data2=”C:\Program Files\MySQL\MySQL Server 5.1\data”
set mysql_cmd=”GRANT ALL PRIVILEGES ON *.* TO ‘root’@'%’ IDENTIFIED BY ‘mysql’ WITH GRANT OPTION;”
msiexec /i %mysql_msi% /qn INSTALLDIR=”C:\Program Files\MySQL\MySQL Server 5.1\” /L* C:\MSI-MySQL-Log.txt
echo MySQL Version 5.1.45 Installed…
md %mysql_data2%
“C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqlinstanceconfig.exe” -i -q ServiceName=MySQL RootPassword=kslimroot ServerType=DEVELOPMENT DatabaseType=MYISAM Port=3306 RootCurrentPassword=kslimroot
echo MySQL Instance Configured…Service Started…
rem Uncomment next line to allow root access from any pc…
“C:\Program Files\MySQL\MySQL Server 6.0\bin\mysql.exe” -uroot -pkslimroot -e %mysql_cmd%
echo on
rem explorer “C:\Program Files\MySQL\MySQL Server 5.1\bin”
================================================================================
After the Setup install MySQL, it will come out MySQL install have problem, do you want to continue.
Can anybody please help me to solve this problem.
Thank you very much.
Comment by kslim — March 10, 2012 @ 3:21 am |
I have done all this. But I want that user will enter the password at the time of installation.
Comment by bhagyashri — March 25, 2013 @ 3:48 am |
HI everybody. I am trying to make a batch file .bat to configure MySql 5.1.54 in Windwos 7.
This is the command:
c:\mysql>MySQLInstanceConfig.exe -i -q “-lC:\mysql\install_log.txt” “-nMySQL Server 5.1″ “-pC:\mysql\Install” -v5.1 “-tC:\mysql\install\my-small.ini” “-cC:\mysql\mytest.ini” ServerType=DEVELOPMENT DatabaseType=MIXED ConnectionUsage=DSS Port=3306 ServiceName=MYSQLCust RootPassword=fernando AddBinToPath=yes
But, the service doesn´t star because the command file (when seen in the service properties in the service administration window of Windows 7) is the following:
“C:\mysql\Install\bin\mysqld-nt” –defaults-file=”C:\mysql\mytest.ini” MYSQLCust
The log file shows exactly the same:
Parameters: “C:\mysql\Install\bin\mysqld-nt” –defaults-file=”C:\mysql\mytest.ini” MYSQLCust
Cannot create Windows service for MYSQLCust. Error: 0
But, the mysqld-nt.exe is not in the bin folder of MySql 5.1.54 because it was removed since 5.1. So, it obviously won´t run, because the file to be referenced to is mysqld.exe instead of mysqld-nt.exe.
How can I make the MySqlInstallConfig.exe references to mysqld.exe and not mysqld-nt.exe when creating the service? I think it is a bug, because the very developers removed the mysqld-nt program.
Thanks in advance.
Comment by Denis — September 13, 2012 @ 7:10 pm |
I have been surfing online greater than 3 hours these days,
but I by no means found any attention-grabbing article like yours.
It’s pretty value enough for me. In my view, if all web owners and bloggers made excellent content as you did, the web shall be much more useful than ever before.
Comment by Gail — January 25, 2013 @ 7:22 pm |