Windows platform configuration 5.7 version + MySQL database service

Windows platform configuration 5.7 version + MySQL database service

Includes the process of initializing the root user password and solutions to two common problems

1. Download the MySQL zip package

Go to [MySQL official website](http://dev.mysql.com/downloads/mysql) and select the zip package to download and decompress it.

For example, now I have downloaded mysql-5.7.17-winx64 on my computer

http://dev.mysql.com/downloads/mysql/

2. Edit MySQL configuration file

Open the unzipped mySQL.zip package and find my-default.ini, which is the default configuration file for MySQL.

It is recommended that you copy a copy and rename it to my.ini

Edit my.ini. Here I only configure the port, the MySQL installation directory, and the MySQL database storage directory.

 > [mysqld]
  > # Set port 3306> port = 3306
  > # Set the MySQL installation directory> basedir=C:\mysql-5.7.17-winx64\mysql-5.7.17-winx64
  > # Set the storage directory of MySQL database data> datadir=C:\mysql-5.7.17-winx64\mysql-5.7.17-winx64\data

3. Install and configure MySQL service

Use admin privileges to open the CMD run window, enter the MySQL bin directory and execute the following install command

C:\mysql-5.7.17-winx64\mysql-5.7.17-winx64\bin>mysqld -install
Service successfully installed.

Run the net start mysql command to start the MySQL service

net start mysql

PS: Question 1

Description: Failed to start the MySQL service

C:\mysql-5.7.17-winx64\mysql-5.7.17-winx64\bin>net start mysql
The MySQL service is starting.
The MySQL service could not be started.
The service did not report an error.
More help is available by typing NET HELPMSG 3534.

Solution:

Through some online searches, I learned that after version 5.7, you need to initialize the bin\data directory before starting the MySQL service.

My approach is:

- Create a bin\data directory, and delete the previous one if it exists - Execute the initialization command in the run window with admin privileges to generate a root user without a password:
    C:\mysql-5.7.17-winx64\mysql-5.7.17-winx64\bin>mysqld --initialize-insecure
  - Try to open the MySQL service again. If nothing unexpected happens, it will return success:

    C:\mysql-5.7.17-winx64\mysql-5.7.17-winx64\bin>net start mysql
    The MySQL service is starting.
    The MySQL service was started successfully.

Check that the MySQL service is started

Run the net start command to list all opened Windows services. Finding MySQL in the output indicates success:

C:\mysql-5.7.17-winx64\mysql-5.7.17-winx64\bin>net start
These Windows services are started:
    ...
  MySQL
    ...

4. Initialize the root user password

Enter MySQL

Since the root we just generated does not come with a password, you can enter MySQL without a password using the following command

mysql -u root

Choose to use MySQL database

mysql> use mysql;

By checking the user table data through SQL statements, you can confirm that root currently has no password

mysql> select user, authentication_string from user;
+-----------+------------------------------------------+
| user | authentication_string |
+-----------+------------------------------------------+
| root | |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
+-----------+------------------------------------------+
2 rows in set (0.00 sec)

Initialize a password for the MySQL root user

mysql> update user set authentication_string=password('password') where user='root';
Query OK, 1 row affected, 1 warning (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 1

PS: Question 2

Description: Initializing the password using the following command failed

mysql> update user set password=PASSWORD('password') where user='root';

Solution:

By checking the user table information, we can see that the password field has been removed in the new version of MySQL user table.

Instead, it is replaced with authentication_string, so using this command will return an error.

Confirm the root user information under the user table again, and you can see that the root user now has a password.

mysql> select user, authentication_string from user;
+-----------+------------------------------------------+
| user | authentication_string |
+-----------+------------------------------------------+
| root | *8B62E5775164CCBD6B3F9FFFC5ABCEFGHIGKLMNO |
| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
+-----------+------------------------------------------+
2 rows in set (0.00 sec)

Run the flush privileges command to make the changes take effect.

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

Exit MySQL

mysql> exit
Bye

Log in to MySQL using the root password

C:\mysql-5.7.17-winx64\mysql-5.7.17-winx64\bin>mysql -u root -p
Enter password: *********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.17 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

The above is the Windows platform configuration version 5.7 + MySQL database service introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Tutorial on installing mysql5.7.18 on windows10
  • Steps to install MySQL 5.7.10 on Windows server 2008 r2
  • Tutorial on installing mysql5.7.17 on windows10
  • MySQL 5.7 installation tutorial (windows)
  • Graphic tutorial on how to modify the initial password of Mysql5.7.11 under Windows
  • Comprehensive analysis of the method of installing mysql5.7 under Windows
  • mysql5.7.13.zip installation tutorial (windows)

<<:  Detailed explanation of modifying the default style of external component Vant based on Vue cli development

>>:  Install centos7 virtual machine on win10

Recommend

Alibaba Cloud Centos7.3 installation mysql5.7.18 rpm installation tutorial

Uninstall MariaDB CentOS7 installs MariaDB instea...

Security considerations for Windows server management

Web Server 1. The web server turns off unnecessar...

MySQL derived table (Derived Table) simple usage example analysis

This article uses an example to describe the simp...

MySQL 5.7.18 installation and configuration method graphic tutorial (CentOS7)

How to install MySQL 5.7.18 on Linux 1. Download ...

Docker creates MySQL explanation

1. Download MySQL Image Command: docker pull mysq...

Detailed tutorial on installing mysql 8.0.13 (rpm) on Centos7

yum or rpm? The yum installation method is very c...

A brief analysis of Linux network programming functions

Table of contents 1. Create a socket 2. Bind sock...

How to implement Docker Registry to build a private image warehouse

The image of the microservice will be uploaded to...

Two methods to implement MySQL group counting and range aggregation

The first one: normal operation SELECT SUM(ddd) A...

The easiest way to make a program run automatically at startup in Linux

I collected a lot of them, but all ended in failu...

Detailed explanation of the simple use of MySQL query cache

Table of contents 1. Implementation process of qu...

User Experience Summary

Nowadays, whether you are working on software or w...

How to use Linux paste command

01. Command Overview The paste command will merge...