Install in Windows

from the Artful MySQL Tips List

1. Log into Windows 2000 or later as a user with Administrator privileges. If this is not an upgrade or downgrade, skip to step 5.

2. Back up my.ini. Back up MySQL data with mysqldump if the upgrade or downgrade crosses 4.0 - 4.1 - 5.0 - 5.1 - 5.4 - 5.5 - 5.6, or if upgrade issues require it:

md c:\backup
mysqldump -uYOUR_MYSQL_USERNAME -pYOUR_MYSQL_PASSWORD -K -E -R -A >c:\backup\mydata.sql

3. If MySQL is running as a service, shut it down by right-clicking on it in My Computer | Manage | Services and Applications | Services. and selecting Stop. Or open a command-line window and issue

net stop MySQL
mysqld --remove

substituting for mysqld, if necessary, the .exe name your service uses. Otherwise stop MySQL with this command from the bin folder of your MySQL installation:


4. If your previous installation is earlier than 4.1.5, or if you are downgrading, remove it. Automatic upgrade is officially safe since 4.1.5, but can go awry, so it can be convenient to rename the current installation folder, then install to a folder of the same name.

5. If you downloaded the Windows installer .msi package, double-click on it from the desktop or Explorer. If you have the no-installer package, it will have a name like; unzip it, respecting folder names, into the root folder of the installation drive. Since 4.0.17, MySQL can cope with spaces in its paths, but in practice they are awkward. Whatever you choose, right-click on the My Computer desktop icon, select Properties | Advanced | Environmental Variables, and make two edits:

(a) set an environment variable named MYSQL_HOME to your full MySQL installation path, or to the bin folder of that installation (depending on how you plan to referto it in commands).

(b) edit the PATH environment variable, remove references to previous MySQL installations, and add the full path to the bin folder of your current MySQL installation.

Remember, Windows remains unaware of these changes until you reboot the machine.

6. From 5.0.2 until 5.5, MySQL for Windows shipped with MySQLInstanceConfig.exe, and offered to run it after files are installed. If this is a first installation, run MySQLInstanceConfig; it walks you through the options, writes my.ini to <MYSQL_HOME>, configures a MySQL service to run

mysqld --defaults-file="<MYSQL_HOME>\my.ini"

then it starts the service for you; skip to Step 12.

Since 5.5, MySQL for Windows has shipped with an all-in-one installer that has MySQLInastanceConfig functionality built-in.

7. If this is an upgrade, MySQLInstanceConfig.exe (or the all-in-1 installer) can configure your server, but in upgrades from 5.4 to 5.5 or 5.5 to 5.6, there are serious problems: without asking, it creates your option file in \Program Files\MySQL\MySQL Server and your data folder in \Documents and Settings\All Users\ Application Data\ MySQL Server , thereby hiding both your existing option file and your existing data folder from your new MySQL server program! Also, if you tell it to use an existing InnoDB data folder, the server will crash at startup because new InnoDB log files don't match the contents of the existing data folder. You can avoid these issues by configuring the option file manually as in Step 8, instead of running MySQLInstanceConfig.

8. Unless you ran MySQLInstanceConfig or are running the all-in-1 installer, copy your previous my.ini to \Program Files\ MySQL\MySQL Server . Use your text editor to update its datadir, INNODB and other settings as required. See Configuration Methods for how to set options, and the INNODB section in Chapter 7.

9. Run the MySQL server in a DOS window from %MYSQL_HOME%\bin with

mysqld --defaults-file="<MYSQL_HOME>\my.ini" --console --skip-grant-tables

substituting for the full path to your installation. To step round a long-unfixed MySQL server bug, always put the defaults-file argument first. In another DOS window, from the installation folder, run

mysql_upgrade -uroot

If the server loads successfully, if InnoDB is enabled it will spit out several lines ending with something like this:

101127 21:35:22  InnoDB: 1.1.3 started; log sequence number 1532574764 

To see what server options can be and have been set, issue

mysqld --verbose --help >c:\mysql\Docs\mysqldopt.txt

Cycle though testing, shutdown, my.ini edits and server restarts till the errors stop.

10. Check for version-specific upgrade issues.

11. Run your mysqldump script from the mysql client:

mysql < backup_path\mysqldumpscript.sql

Then stop the server with

mysqladmin -uroot shutdown

and restart it in My Computer | Manage | Services and Applications | Services.

12. Connect with the MySQL client from <MySQL_HOME>\bin:


Test, and test again.

Return to the Artful MySQL Tips page