PowerShell Basics: How to Install MySQL on a Nano Server

This post has been republished via RSS; it originally appeared at: ITOps Talk Blog articles.

Some time ago, Pierre and I were delivering a Windows Server session to the Toronto ITPRO Usergroup when the following was asked:


“Can you install SQL on a Nano Server?”  


SQL requires lots of features to be enabled in the underlying operating system. While it is possible to install SQL on a Server Core offering of Windows Server, albeit painful, SQL cannot be installed on a Nano Server at the time of this post being published. There is a possibility of SQL enablement that could occur with the utilization of containers which we’ll explore in a later post.   With this in mind, it is possible to natively install MySQL on Nano. While it may not be as robust as SQL, for some this may just do the trick. This How-To post will detail the process required to complete this.  


Step 1: Setup a Nano Server VM 


Step 2: Installing MySQL on Nano Server

  1. Download mysql-8.0.15-winx64.zip and unzip the file to a local folder on your admin machine
  2. Rename the innermost mysql-8.0.15-winx64 folder to MySQL
  3. Run the following PowerShell script from an elevated PowerShell console to copy the binaries to your Nano Server machine:
    $ip = “” # Nano Server IP address
    $s = New-PSSession -ComputerName $ip -Credential ~\Administrator
    Copy-Item -ToSession $s -Path .\MySQL” -Destination C:\ -Force -Recurse


Step 3: Setting up your environment

  1. Remote into your newly created Nano Server machine and enter the following:
    Enter-PSSession $s
  2. Enter the following to add the MySQL\bin folder to your path environment variable:
    $env:path += “;C:\MySQL\bin”
  3. Next you need to enter the following to make this change persist even after the Nano Server reboots:
    setx PATH $env:path /M
  4. Now enter the following to ensure the MySQL instance is present:
    mysql –version   # displays the MySQL version
  5. Enter the following to initialize the MySQL daemon and ignore the warnings for now:
    mysqld –initialize –console
  6. Create mysql-init.txt and replace PASSWORD with your own:
    Set-Content -Value “ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘PASSWORD’;” -Path c:\mysql\mysql-init.txt -Encoding Ascii
  7. Pass mysql-init.txt to the MySQL daemon for initialization:
    mysqld –init-file=c:\\mysql\\mysql-init.txt –console
  8. Stop the daemon using Ctrl+C and type the following to install the service:
    mysqld –install
  9. The service is now installed, and needs to be started with the following:
    Get-Service MySQL
    Start-Service MySQL
    Get-Service MySQL
  10. Display the system databases using the assigned password established when mysql-init.txt was created and yes ignore the warning:
    mysql –user=root –password=myPassword -Bse “SHOW DATABASES;” > mydatabase.txt
      NOTE: The output to a file is being redirected to a text file as interactive sessions are not supported
  11. Enter the following to display the content of the mydatabase.txt

MySQL is now operational on Nano Server.

REMEMBER: these articles are REPUBLISHED. Your best bet to get a reply is to follow the link at the top of the post to the ORIGINAL post! BUT you're more than welcome to start discussions here:

This site uses Akismet to reduce spam. Learn how your comment data is processed.