How to Install MySQL Zip File on Windows – A Step by Step Guide

In this tutorial, we’ll discuss how to install MySQL Zip File on Windows (MySQL Portable). Tested on Windows 10, but it should work on other versions of Windows.

Actually, there are a lot of ways we can do to run MySQL without installing it, one way is to use XAMPP Portable, that we have discussed in the previous tutorial: How To Install XAMPP On Windows – A Complete Guide

However, now, XAMPP do not include MySQL anymore (because of Oracle?), it replaced by Maria DB. The last version of MySQL supported by XAMPP was 5.6.

As an alternative, we can use WAMP server or EasyPHP which are still consistent using MySQL, but we still have to install them (lack of portable version).

So, till this date, we can’t install MySQL portable except install MySQL Zip File.

I. Install MySQL Zip File on Windows (MySQL Portable)

In order to be able to install MySQL zip file on Windows, follow these steps:

1 Download and Extract The Zip File

First of all, download the MySQL zipped file by visiting the official download page on

Download MySQL Zip File From MySQL Webpage

Choose the zip file according to your Windows architecture, 32 bit or 64 bit. In this tutorial, I use the 64-bit version. Then, on the next page, if you don’t want to login/register just click the link No thanks, just start my download

Download MySQL Zip File Without Login

Next, extract the zip file we have downloaded. In this example, I extract it to a directory of E:\mysql-5.7.17 The extracted files look like the following figure:

The Content of MySQL Zip File

2 Add a data Folder and Create a Configuration File

Next, we need to create a folder that will be used for MySQL to place the database files and all correspondent data files such as data tables, stored routines, etc.

On MySQL version 5.6 and earlier, all of the data files are stored by default in a data folder, which is already included in the zip file that we downloaded.

However, starting from MySQL version 5.7, that folder has been removed and now, we are free to choose the name and the location of the folder.

For simplicity, we name the folder data and we place it in the main folder (E:\mysql-5.7.17). In Addition, we also need to create a configuration file named my.ini

The data Folder and The my.ini File

3 Add Some Parameters

Next, we need to add some parameters to the my.ini file. These parameters will be used by MySQL to perform various configuration at runtime.

For simplicity, copy and paste the contents of the my-default.ini file into the my.ini file, then, open that file with notepad (or notepad ++). Next, under [mysqld] section, add the following parameters:

basedir = "/mysql-5.7.17"
datadir = "/mysql-5.7.17/data"
tmpdir = "/mysql-5.7.17/tmp"
port = 3306
server_id = 1
log_error = "mysql_error.log"
pid_file = ""
socket = "/mysql-5.7.17/mysql.sock"

# Optional - Default Configuration
max_allowed_packet = 8M

# Where do all the plugins live
plugin_dir = "/mysql-5.7.17/lib/plugin/"
basedir = "/mysql-5.7.17"
datadir = "/mysql-5.7.17/data"
port = 3306
server_id = 1
log_error = "mysql_error.log"
pid_file = ""
socket = "/mysql-5.7.17/mysql.sock"

# Optional - Default Configuration
max_allowed_packet = 8M

# Where do all the plugins live
plugin_dir = "/mysql-5.7.17/lib/plugin/"

The content of my my.ini file looks like the following:

MySQL Configuration

The Optional – Default Configuration section is optional, you can remove or change it as needed. Reference to the configurations can be found on the official page:

In addition, we store all MySQL error to mysql_error.log file, otherwise, MySQL will automatically create a file with extension of .err to handle the error message, this also happened to the pid_file and socket configuration file

4 Initialization For The First Time

Furthermore, to be able to run MySQL, first, we need to initialize it. We run this process only once.

This process will create necessary files and databases that used to run MySQL including making a username and optionally a password and set privileges to the user.

There are two statements that we can use to initialize (we must choose one)

mysqld --initialize
mysqld --initialize-insecure

The Difference is: mysqld --initialize will create a random password that written to the log file, in this example mysql_log.log file located in the data folder.

While for mysqld --initialize-insecure, there is no password to be set, Nevertheless, we can still create a password later.

By default, the process will create a user to login with root as the username, we can define another username by adding --user option, e.g. mysqld --initialize-insecure --user=agusph

For simplicity, in this example, we will initialize using the default username ( root ) without a password. Open a command prompt and navigate the cursor to the bin folder, then, run the command mysqld --initialize-insecure

How to Install MySQL Zip File on Windows

Wait for a while until the process complete, if successful, the data folder will contain files and folders as shown in the following figure:

The Content of The data Folder After Initialization

5 MySQL is Ready To Use

At this step, MySQL is ready to use. To be able to use MySQL, we need to run the MySQL server. Open a command prompt and type the command mysqld, if successful, the cursor will not return to E:\mysql-7.5.17\bin, as shown below:

Successfully Run MySQL Server

If the cursor back to E:\mysql-5.7.17\bin then some errors has occurred, to solve it, see section II at the bottom of this tutorial.

Now, you can close the command prompt window, although closed, the MySQL server will still running (exists in Windows Task Manager on Processes section).

At this step, we can now use MySQL using root as the username without a password. We can try it using a command prompt or database management application such as phpMyAdmin, HeidiSQL, or Toad for MySQL.

Let’s try with the command prompt. Open a command prompt and then point the cursor to E:\mysql-7.5.17\bin, then type the command mysql -u root

If successful, the pointer will change to mysql> such as the following

Running MySQL Using Command Prompt

6 Shutdown The MySQL Server

Mysql server that has been started, will still live until we turn it off manually or we restart our computer. The MySQL server can be seen in the Windows Task Manager (in Windows 7+ press Ctrl+Shift+Esc)

MySQl Server on Windows Task Manager

To turn it off, we can use the command mysqladmin -u root shutdown as follows:

Shutdown The MySQL Server Using a Command Prompt

If it already turned off, and we run the command, we’ll get an error message like the following:

mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to MySQL server on 'localhost' (10061)'
Check that mysqld is running on localhost and that the port is 3306.
You can check this by doing 'telnet localhost 3306'

II. Install MySQL Zip File – Handling Error

Sometimes, the installation process did not run in smooth, some error may occur and some of them known when we run the MySQL server using the mysqld command.

As we have discussed previously, if we run mysqld and the cursor back to the bin directory E:\mysql-5.7.17\bin then it signs that some errors have been occurred, for example:

An Error Occured When Running MySQL Server


To discover the cause of the error, open the error log file, in this example mysql_error.log file, then find the messages that contains ERROR word, eg:

Handling Error While Installing MySQL Zip File

In the example above,  the error occurs because incorrect type of the command option –initialize-unsecure, while it should be --initialize-insecure (using i, instead of u),

To solve that, we have to run the command again mysqld --initialize-insecure, Note that before executing the command, we have to empty the data folder

Or it could be like this:

MySQL Error: Port 3306 Already Used

means that port of 3306 has been used, there could be another MySQL that run using that port. In the real world, the type of error can be vary, always check the error log file to investigate the error.

In this tutorial, we have discussed how to install MySQL zip file on windows, hope it help.

Subscibe Now

Loves articles on join our newsletter to get quality article right to your inbox. Nothing else, just quality stuff!!!

Our Commitment: We respect your privacy, we'll not share your credential to any party

38 Responses

  • @waleed as mysql version 5.7.18, the zip version doesn’t include my-default.ini anymore. Create it manually. Just copy and paste above code, edit it according to your need, save it as my.ini.

    • Hi, it seems that the plugin table in the MySQL database does not exist. You can check it using database browsers tool such as phpMyAdmin and open a database named mysql.

      To solve that, you could try to impor the plugin table from other mysql database.

  • i have MySQL server 5.7 installer and i also have xampp running on my window. I want to upgrade MySQL server on my xampp using MySQL server installer. Is that possible?

    • Hi you can do that but with sparate mysql installation (cannot replace mysql in xampp)

      In addition we have to run the new MySQL manually, or we can install it to the windows service to make it run with windows.

      With that configuration, mysql module in xampp does not usefull anymore

      • Ok, you just hit the target. The reasons for the question was that i was trying to conmect my Dreamweaver to my database on my Phpmyadmin. But its returns an error message similar to what you just said. This is the error message

        “Your PHP server doesn’t have the MySQL module loaded or you can’t use the mysql_(p) conmect functions”.

        Please i have been stock here for weeks, Trying all suggestion and solutions, yet no positive achievement. Do you know what might cause this? My server is running fine and everything seems ok. Exception of this error message.

        • Hi, I don’t khow exactly what the problem is.

          From the error message, it seems that your PHP version doesn’t support mysql_xxx function. That function depends on MySQL module located in the php/ext folder. phpmyadmin try to use musql_xxx function but fail, so that it raised an error.

          As of PHP 7 and above, that function was removed and replaced by mysqli_xxx instead, so the module doesn’t exist anymore…

          So please check your phpmyadmin, upgrade it to the latest version

  • i have upgraded phpmyadmin to version 4.7.5, which is the latest but still giving me issue. I think the problem is with Mysql and not phpmyadmin. What do you think cos am not an expert o this.

    • Hi, I think the problem is in php, especially in mysql module. Phpmyadmin want to use function that associate with the mysql module but it is not available in the php

      Try to test using your own php script to connect to mysql database,or you can send me email the error screenshot

  • Hello sir

    So sorry if i am posting on the wrong page.

    I have a form for login system but whenever i test it on my local server and click the login page, its responds well but when i click sign up, i get this error.

    Notice: Undefined variable: _user in C:\xampp\htdocs\phpacademy\register.php on line 7
    Notice: Undefined variable: _user in C:\xampp\htdocs\phpacademy\register.php on line 8
    Notice: Undefined variable: _user in C:\xampp\htdocs\phpacademy\register.php on line 9
    Notice: Undefined variable: mysqli in C:\xampp\htdocs\phpacademy\register.php on line 12
    Fatal error: Call to a member function escape_string() on null in C:\xampp\htdocs\phpacademy\register.php on line 12.

    Below is the code for line 7,8,9,12 in the register.php.

    // Set session variables to be used on profile.php page
    $_SESSION['email'] = $_POST['email'];
    $_SESSION['first_name'] = $_POST['firstname'];
    $_SESSION['last_name'] = $_POST['lastname'];
    // Escape all $_POST variables to protect against SQL injections
    $first_name = $mysqli->escape_string($_POST['firstname']);
    $last_name = $mysqli->escape_string($_POST['lastname']);
    $email = $mysqli->escape_string($_POST['email']);
    $password = $mysqli->escape_string(password_hash($_POST['password'], PASSWORD_BCRYPT));
    $hash = $mysqli->escape_string( md5( rand(0,1000) ) );

    Please is there anything wrong with this lines of code?? Am stock here for days.

    • Hi, no problem

      You must understand the keyword of the error message.
      “Undefined” means doesn’t exists, means PHP can’t find it, for example we just write this:

      echo $user;

      We directly use $user variable but don’t initiate it first, So PHP tells us that the $user variable is Undefined, to solve this, before we use any variable, we must initiate it first, for example:

      $user = ‘a’;
      echo $user;

      This is same as your case, for example on the error message:

      Undefined variable: mysqli

      We use $mysqli variable in many places ($mysqli->xxx) and do not initiate it first, so initiate it first, for example:
      $mysql = new mysqli(‘localhos’, ‘user’, ‘password’, ‘database_name’);

      Hope it helps…

  • Its didn’t work.

    i made some changes in lime 7,8,9 and Here it is.

    $_SESSION [’email’] = “;
    $_SESSION [‘first_name’] = “;
    $_SESSION [‘last_name’] = “;

    After this, i didn’t get the undefined notice again for line 7,8 and 9 but line 12 error still displaying.

    Since your suggestion didn’t work, do you think i am doing it right?

    • Hi, try to declare $mysqli variable before any use of that variable, for example:

      // Escape all $_POST variables to protect against SQL injections
      $mysqli = new mysqli(‘localhos’, ‘user’, ‘password’, ‘database_name’);
      $first_name = $mysqli->escape_string($_POST[‘firstname’]);
      $last_name = $mysqli->escape_string($_POST[‘lastname’]);

  • Thank you for your simple but complete and thorough tutorial.

    I would add one step I encountered : the need to install Microsoft visual C++ 2013 package in order to have the mysqld –initialize command executed (step 4).

  • Perfect and clear! In my.ini I had to use absolute paths to make it work. I did not manage to disable it using the command mysqladmin -u root shutdown:
    C:\mysql57\bin>mysqladmin -u root shutdown
    mysqladmin: connect to server at ‘localhost’ failed
    error: ‘Access denied for user ‘root’@’localhost’ (using password: NO)’
    I should install the service?
    Thank you

    • Hi, thank you

      The error message tells that the mysql server ia running but unable to connect using username root (user root) without password (using password :NO)

      Please check your username and password again

      The service used just for running the mysql server (automatically when windows start), your mysql server already running but unable to logged in

  • C:\mysql\bin>mysqld –initialize-insecure
    mysqld: [ERROR] Found option without preceding group in config file C:\mysql\my.ini at line 1!
    mysqld: [ERROR] Fatal error in defaults handling. Program aborted!

    i am having this error what should i do now

  • Hi ,

    I am getting the below error while starting the mysqld

    mysqld: Could not create or access the registry key needed for the MySQL application
    to log to the Windows EventLog. Run the application with sufficient
    privileges once to create the key, add the key manually, or turn off
    logging for that application.
    2018-04-11T07:56:12.586473Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use –explicit_defaults_for_timestamp server option (see documentation for more details).
    2018-04-11T07:56:12.589846Z 0 [ERROR] Cannot open Windows EventLog; check privileges, or start server with –log_syslog=0
    2018-04-11T07:56:12.596154Z 0 [ERROR] –initialize specified but the data directory has files in it. Aborting.
    2018-04-11T07:56:12.596551Z 0 [ERROR] Aborting

    Could you please help me what is issue here.

    Appreciate your help.

  • Hi,

    I am getting below error while running the mysqld initialization. Could please guide on the same. Thanks!

    C:\QlikSenseRoot\mysql-5.7.21\bin>mysqld –initialize-insecure
    mysqld: [ERROR] Found option without preceding group in config file C:\QlikSense
    Root\mysql-5.7.21\my.ini at line 1!
    mysqld: [ERROR] Fatal error in defaults handling. Program aborted!

  • Hello,

    I have mysql 5.0.22 with myISAM databases, and i wanted to upgrade it to mysql 8. I used the ZIP method and configured the new version with mysqld –initialize, but with an empty data folder (as i had an error when putting my old myIsam databases in it : 2018-07-24T07:59:03.592367Z 0 [ERROR] [MY-010457] [Server] –initialize specified but the data directory has files in it. Aborting.).
    The mysql service started successfully.
    Then, i put my database files in the data folder and run mysql_upgrade, i douln’t recover them, neither recover old users.
    How to recover my myISAM databases please ? Anyoune can help me please ??

    Thanks a lot.
    Best regards,

    • Hi, from mysql 5.0 there must be alot of difference in database structure compared to mysql 8,I have many experience with it

      We can’t simply copy and paste the data folder

      The only solution is, try to install mysql 8 with default data folder (if you want to re install it, you must empty the data folder), export your database form mysql 5.0,then import it to mysql 8

      Hope it help

  • The title of the post is a lie. This does not include the information necessary to install anything. All it has is hand waving skipping key points and a lot of wishful thinking.

    • Hi, thank you very much for your feedback. I write the tutorial honestly and not intended to lie visitors to get traffic, so please let me know what information did you search for until you land to this page

  • Using your web page instructions I was able to get mysql running and workbench to connect. My pc ran out of battery and system shut down couple days later/hard shut down.

    Now when i try to bring up mysql again I get ‘Can’t connect to MySQL server on ‘localhost’ ‘ .

    I think i got this message originally, when i initialized with ‘mysqld –initialize’ , I then tried ‘mysqld –initialize-insecure’ and it worked.

    Anyhow, I removed the /data directory, and did ‘mysqld –initialize-insecure’ and now I get the ‘Can’t connect to MySQL server on ‘localhost’ .

    Any thoughts?

  • This is a great tutorial. After following the tutorial set by step, I was able to successfully install mysql on my windows 10 machine.

    Just a few things to take into consideration before following this tutorial:

    1: If you are using the same my.ini entries as stated in the tutorial, make sure you create the tmp directory in your base MYSQL installation directory (mysql-5.7.17):

    tmpdir = “/mysql-5.7.17/tmp”

    When I ran the following command:

    mysqld –initialize-insecure

    WITHOUT creating the tmp directory, I got the following error:

    “InnoDB: Error: unable to create temporary file; errno: 2 ”

    2: As stated by JEROME, you need to install Microsoft visual C++ 2013 package in order to have the mysqld –initialize command executed (step 4).

    You can download it from here:
    64 bit:

    32 bit:

    Congratulations to the author for such a great tutorial.

Leave a comment

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

Like Us


Great information from right to your inbox

  1. Understanding JSONP – With Javascript and jQuery Examples

  2. JSON With Javascript and Ajax

  3. JSON From Database – PHP and MySQL

  4. JSON in HTML Document

  5. JSON With PHP – A Complete Guide

  6. Understanding JSON – A Comprehensive Guide

  7. 7 Best Free Online Image Compressor & Optimizer Tools – Compared & Tested

  8. 40+ Modern Free WordPress Themes For Blog in 2017 – Beautiful & Responsive

  9. Understanding Constant in PHP – Updated to PHP 7

  10. Understanding Variable in PHP – All PHP Version