Install MySQL 5.6 when MySQL 8.0 is installed in win10 (install two mysql, and install the lower version in the higher version)

Keywords: MySQL Database

Install MySQL 5.6 when MySQL 8.0 is installed in win10 (install two mysql, and install the lower version in the higher version)


Recently with a senior project, we need to use database. Originally, I used mysql8.0, but I used mysql5.6 to search the Internet. Most of them were upgraded from the lower version (5.6 or 5.7) to the higher version (8.0), so I tried it myself.

Shut down the installed mysql service

First, shut down the mysql service you have installed

Download and unzip mysql5.6

Next, download a mysql5.6 compression package and unzip it to the directory. There are many online tutorials in this part, which will not be described in detail.

Configure environment variables

The system variable adds mysql5 6_home, which is the path of mysql5.6. The name is actually arbitrary. It is different from the previous version of the system variable.

Then add * *% mysql56 ﹐ home% \ bin to the path.**

Modify my.ini configuration file

Open the directory of mysql5.6, create a new my.ini configuration file, and open it with Notepad. Copy the following and paste it into the INI file, then exit saving.

The port number is recommended to be 3307. The default port number of mysql is 3306. This port number is probably used by the existing higher version of mysql on the computer, so you need to change the port number.

basedir and datadir should be changed to their own.

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.

[client]
port=3307

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
basedir=mysql5.6 Directory
datadir=mysql5.6 Directory\data
port=3307
# server_id = .....
character-set-server=utf8


# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M 

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

Install mysql service

Run cmd as an administrator, or you do not have sufficient privileges.

Enter the absolute path of cd mysql5.6 \ bin, and enter the bin file of MySQL

After that, unzip the modified my.ini file in the directory, and enter the service installation command: mysqld install MySQL service name -- defaults file = "mysql path \ my.ini". The service name is arbitrary, which is different from the previous version. After the installation is successful, you will be prompted that the service installation is successful.
(if the installation error, the remove service command is mysqld remove service name)
Enter the net start MYSQL service name to start the service.

Change Password

Change the root password of mysql

 c:>mysql -h localhost –u root -p
    mysql>show databases;
    mysql>use mysql;
    mysql>UPDATE user SETpassword=PASSWORD("123456") WHERE user='root';
    mysql>FLUSH PRIVILEGES;
    mysql>QUIT

This is done. You can use different versions of mysql to close and open the corresponding mysql service. Pay attention to the port number when the new project is connected.

If it helps you, please like it.

Posted by RossC0 on Sat, 26 Oct 2019 06:35:43 -0700