In addition to using the GUI interface to the MySQL Server Instance Config Wizard, you can also create instances automatically from the command line.
To use the MySQL Server Instance Config Wizard on the command
line, you need to use the
MySQLInstanceConfig.exe command that is
installed with MySQL in the bin
directory
within the installation directory.
MySQLInstanceConfig.exe takes a number of
command-line arguments the set the properties that would
normally be selected through the GUI interface, and then creates
a new configuration file (my.ini
) by
combining these selections with a template configuration file to
produce the working configuration file.
The main command line options are provided in the table below. Some of the options are required, while some options are optional.
Table 2.4. MySQL Server Instance Config Wizard Command Line Options
Option | Description |
---|---|
Required Parameters | |
-nPRODUCTNAME |
The name of the instance when installed |
-pPATH |
Path of the base directory for installation. This is equivalent to the
directory when using the basedir
configuration parameter |
-vVERSION |
The version tag to use for this installation |
Action to Perform | |
-i |
Install an instance |
-r |
Remove an instance |
-s |
Stop an existing instance |
-q |
Perform the operation quietly |
-lFILENAME |
Sae the installation progress in a logfile |
Config File to Use | |
-tFILENAME |
Path to the template config file that will be used to generate the installed configuration file |
-cFILENAME |
Path to a config file to be generated |
The -t
and -c
options work
together to set the configuration parameters for a new instance.
The -t
option specifies the template
configuration file to use as the basic configuration, which are
then merged with the configuration parameters generated by the
MySQL Server Instance Config Wizard into the configuration file
specified by the -c
option.
A sample template file, my-template.ini
is
provided in the toplevel MySQL installation directory. The file
contains elements are replaced automatically by the MySQL Server
Instance Config Wizard during configuration.
If you specify a configuration file that already exists, the
existing configuration file will be saved in the file with the
original, with the date and time added. For example, the
mysql.ini
will be copied to mysql
2009-10-27 1646.ini.bak
.
The parameters that you can specify on the command line are listed in the table below.
Table 2.5. MySQL Server Instance Config Wizard Parameters
Parameter | Description |
---|---|
ServiceName=$ |
Specify the name of the service to be created |
AddBinToPath={yes | no} |
Specifies whether to add the binary directory of MySQL to the standard
PATH environment variable |
ServerType={DEVELOPMENT | SERVER | DEDICATED} |
Specify the server type. For more information, see Section 2.5.4.4, “The Server Type Dialog” |
DatabaseType={MIXED | INNODB | MYISAM} |
Specify the default database type. For more information, see Section 2.5.4.5, “The Database Usage Dialog” |
ConnectionUsage={DSS | OLTP} |
Specify the type of connection support, this automates the setting for
the number of concurrent connections (see the
ConnectionCount parameter). For more
information, see
Section 2.5.4.7, “The Concurrent Connections Dialog”
|
ConnectionCount=# |
Specify the number of concurrent connections to support. For more information, see Section 2.5.4.4, “The Server Type Dialog” |
SkipNetworking={yes | no} |
Specify whether network support should be supported. Specifying
yes disables network access
altogether |
Port=# |
Specify the network port number to use for network connections. For more information, see Section 2.5.4.8, “The Networking and Strict Mode Options Dialog” |
StrictMode={yes | no} |
Specify whether to use the strict SQL mode. For more
information, see
Section 2.5.4.8, “The Networking and Strict Mode Options Dialog”
|
Charset=$ |
Specify the default character set. For more information, see Section 2.5.4.9, “The Character Set Dialog” |
RootPassword=$ |
Specify the root password |
RootCurrentPassword=$ |
Specify the current root password then stopping and/or reconfiguring an existing service |
When specifying options on the command line, you can enclose
the entire command-line option and the value you are
specifying using double quotes. This enables you to use spaces
in the options. For example,
"-cC:\mysql.ini"
.
The following command installs a MySQL Server 5.1 instance from
the directory C:\Program Files\MySQL\MySQL Server
5.1
using the service name MySQL51
and setting the root password to 1234.
shell> MySQLInstanceConfig.exe -i -q "-lC:\mysql_install_log.txt" » "-nMySQL Server 5.1" "-pC:\Program Files\MySQL\MySQL Server 5.1" -v5.1.39 » "-tmy-template.ini" "-cC:\mytest.ini" ServerType=DEVELOPMENT DatabaseType=MIXED » ConnectionUsage=DSS Port=3311 ServiceName=MySQL51 RootPassword=1234
In the above example, a log file will be generated in
mysql_install_log.txt
containing the
information about the instance creation process. The log file
generated by the above example is shown below:
Welcome to the MySQL Server Instance Configuration Wizard 1.0.16.0 Date: 2009-10-27 17:07:21 Installing service ... Product Name: MySQL Server 5.1 Version: 5.1.39 Installation Path: C:\Program Files\MySQL\MySQL Server 5.1\ Creating configuration file C:\mytest.ini using template my-template.ini. Options: DEVELOPMENT MIXED DSS STRICTMODE Variables: port: 3311 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: "MySQL51" Parameters: "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld" --defaults-file="C:\mytest.ini" MySQL51. Windows service MySQL51 installed.
When using the command-line, the return values in the following table indicate an error performing the specified option.
Table 2.6. Return Value from MySQL Server Instance Config Wizard
Value | Description |
---|---|
2 | Configuration template file cannot be found |
3 | The Windows service entry cannot be created |
4 | Could not connect to the Service Control Manager |
5 | The MySQL service cannot be started |
6 | The MySQL service cannot be stopped |
7 | The security settings cannot be applied |
8 | The configuration file cannot be written |
9 | The Windows service entry cannot be removed |
You can perform an installation of MySQL automatically using the MSI packe. For more information, see Section 2.5.3.2, “Installing MySQL Automatically using MSI”.
User Comments
Add your own comment.