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

Summary of learning HTML tags and basic elements

1. Elements and tags in HTML <br />An eleme...

How to start multiple MySQL databases on a Linux host

Today, let’s talk about how to start four MySQL d...

Vue.js implements the nine-grid image display module

I used Vue.js to make a nine-grid image display m...

HTML+CSS to achieve drop-down menu

1. Drop-down list example The code is as follows:...

Linux /etc/network/interfaces configuration interface method

The /etc/network/interfaces file in Linux is used...

Summary of discussion on nginx cookie validity period

Every visit will generate Cookie in the browser, ...

How to add interface listening mask in Vue project

1. Business Background Using a mask layer to shie...

Linux Centos8 Create CA Certificate Tutorial

Install Required Files Yum install openssl-* -y C...

How can MySQL effectively prevent database deletion and running away?

Table of contents Safe Mode Settings test 1. Upda...

Install Linux using VMware virtual machine (CentOS7 image)

1. VMware download and install Link: https://www....

Mini Programs use Mini Program Cloud to implement WeChat payment functions

Table of contents 1. Open WeChat Pay 1.1 Affiliat...

How to use JS to check if an element is within the viewport

Preface Share two methods to monitor whether an e...

Summary of the Differences between find() and filter() Methods in JavaScript

Table of contents Preface JavaScript find() Metho...