MySQL - Windows installation
author: Paul Kim
categories: mysql
tags: mysql
Install MySQL (using ZIP archive)
-
Extract zip archive(s) to the desired install directory
C:\mysql\mysql-5.6.44-winx64 C:\mysql\mysql-5.7.26-winx64 C:\mysql\mysql-8.0.16-winx64
- Optional: Extract debug-test archive if you plan to execute the MySQL benchmark and test suite
-
Optional: Create an option file (
my.ini
ormy.cnf
) in C: drive (i.e.,C:\my.ini
).[mysqld] basedir = C:/mysql datadir = C:/mysql/data
- Add
%MYSQL_HOME%\bin
toPATH
. For example,MYSQL_HOME
points toC:\mysql\mysql-8.0.16-winx64
. -
Open Command Prompt and initialize MySQL: Create the data directory and populate tables in the mysql system database
# no password (just use this) mysqld --initialize-insecure # or temp password mysqld --initialize --console # other options mysqld --initialize --user=mysql mysqld --initialize --basedir=C:/mysql --datadir=C:/mysql/data mysqld --initialize --defaults-file=C:\my.ini
-
Start MySQL:
mysqld --console
-
Open a new Command Prompt and secure MySQL:
mysql_secure_installation
-
Connect to MySQL:
mysql -u root -p
Install MySQL as a service
# run as Administrator
# install MySQL as a service (just use this)
mysqld --install
# install MySQL as a manual service
mysqld --install-manual
# other options
mysqld --install MySQL --defaults-file=C:\my.cnf
Start/Stop MySQL service
# run as Administrator
sc query mysql
sc start mysql
sc stop mysql
net start mysql
net stop mysql
Remove MySQL service
# run as Administrator
# remove mysql service
mysqld --remove
sc delete mysql
Uninstall MySQL
- Remove
%MYSQL_HOME%\bin
fromPATH
environment variable - Remove Inbound Rules for MySQL from Windows Firewall (wf.msc)
Test MySQL installation
mysqlshow -u root -p
mysqlshow -u root -p information_schema
mysqlshow -u root -p mysql
mysqlshow -u root -p performance_schema
mysqlshow -u root -p sys
mysqladmin -u root -p version status proc