Follow these simple steps to install MySQL on Windows.
Step 1: Download MySQL
Download MySQL from dev.mysql.com/downloads/. Follow MySQL Community Server, Windows and download the “Without installer” version.
Step 2: Extract the files
We will install MySQL to C:\mysql, so extract the ZIP to your C: drive and rename the folder from “mysql-x.x.xx-win32″ to “mysql”.
MySQL can be installed anywhere on your system. If you want a lightweight installation, you can remove every sub-folder except for bin, data, scripts and share.
Step 3: Create a configuration file
MySQL provides several configuration methods but, in general, it is easiest to to create a my.ini file in the mysql folder. There are hundreds of options to tweak MySQL to your exact requirements, but the simplest my.ini file is:
[mysqld]
# installation directory
basedir=”C:/mysql/”
# data directory
datadir=”C:/mysql/data”
(Remember to change these folder locations if you have installed MySQL or the data folder elsewhere.)
Step 4: Test your installation
The MySQL server is started by running C:\mysql\bin\mysqld.exe. Open a command box (Start > Run > cmd) and enter the following commands:
cd \mysql\bin
mysqld
This will start the MySQL server which listens for requests on localhost port 3306. You can now start the MySQL command line tool and connect to the database. Open another command box and enter:
cd \mysql\bin
mysql -u root
This will show a welcome message and the mysql> prompt. Enter “show databases;” to view a list of the pre-defined databases.
Step 5: Change the root password
The MySQL root user is an all-powerful account that can create and destroy databases. If you are on a shared network, it is advisable to change the default (blank) password. From the mysql> prompt, enter:
UPDATE mysql.user SET password=PASSWORD(“my-new-password”) WHERE User=’root’;
FLUSH PRIVILEGES;
You will be prompted for the password the next time you start the MySQL command line.
Enter “exit” at the mysql> prompt to stop the command line client. You should now shut down MySQL with the following command:
mysqladmin.exe -u root shutdown
Step 6: Install MySQL as a Windows service
The easiest way to start MySQL is to add it as a Windows service. From a command prompt, enter:
cd \mysql\bin
mysqld –install
Open the Control Panel, Administrative Tools, then Services and double-click MySQL. Set the Startup type to “Automatic” to ensure MySQL starts every time you boot your PC.
Alternatively, set the Startup type to “Manual” and launch MySQL whenever you choose using the command “net start mysql”.
Note that the Windows service can be removed using:
cd \mysql\bin
mysqld –remove