Installation of the MySQL Windows 10 using Powershell

You can download the last MySQL server zip file directly from the web page. There are several steps such as1:

First part of the script extracts the zip to destination

$BackUpPath = “D:\WebDevelopment\”

$Destination = “D:\Install\”

Add-Type -assembly “”

[io.compression.zipfile]::ExtractToDirectory($BackUpPath, $destination)

Second part is to copy my.ini to MySQL folder

if ([System.IO.File]::Exists(‘D:\Install\MySQL51\my.ini’))
mv d:\Install\MySQL51\my.ini d:\Install\MySQL51\my.ini_bak
cp d:\WebDevelopment\my.ini d:\Install\MySQL51 -Force

cp d:\WebDevelopment\my.ini d:\Install\MySQL51

Finally you install the Mysql service

“D:\Install\MySQL51\bin\mysqld” –install MySQL51 –defaults-file=”D:\Install\MySQL51\my.ini”

Create an exclusion in the Firewall
New-NetFirewallRule -displayName “MySQL 3307” -LocalPort 3307 -Protocol TCP -Action Allow

This is an old way, which I did without Powershell.

  • You should extract the file into the folder e.g. D:\MySQL\server
  • Run Command line and type net user Administrator /Active :yes
  • This enables in-built Account Administrator
  • Next step is to run command line with administrator privilegies
  • runas /noprofile /user:David-PC\Administrator cmd
    Write password for David-PC\Administrator:
  • type cd %programfiles%
  • We need to look for MySQL directory if it is already located in %programfiles%
  • dir “*MySQL*” /s/a:d
  • The last step is to copy MySQL server in the %programfiles% directory
  • xcopy D:\MySQL\server\mysql_server_5.1.50_win32 “Pro
    gram files\MySQL\” /s /e
  • The last step is to edit my.ini with the pspad and set the format as ANSI
  • Finally install the service
  • install the MySQL service “C:\Program Files\MySQL51\server\bin\mysqld” –install MySQL51 –defaults-file=”C:\Program Files\MySQL51 \server\my.ini”
  • Start the service
  • sc start MYSQL51
  • Check if the service is running
  • sc qc MySQL51
  • sc query type=service state=running | sc qc MySQL51
  • sc query type= service | find /v “x0” | find /i “MySQL”
  • Disable Super Administrator account
  • net user Administrator /Active :no
  • log in to MySQL server
  • cd “c:\Program Files\mysql\MySQL Server 5.0\bin”
  • mysql -u root -p