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

Detailed explanation of the basic usage of the img image tag in HTML/XHTML

The image tag is used to display an image in a we...

Linux server quick uninstall and install node environment (easy to get started)

1. Uninstall npm first sudo npm uninstall npm -g ...

What qualities should a good advertisement have?

Some people say that doing advertising is like bei...

How to use mysqladmin to get the current TPS and QPS of a MySQL instance

mysqladmin is an official mysql client program th...

CentOS 7.9 installation and configuration process of zabbix5.0.14

Table of contents 1. Basic environment configurat...

Windows 2019 Activation Tutorial (Office2019)

A few days ago, I found that the official version...

Detailed explanation of CSS margin collapsing

Previous This is a classic old question. Since a ...

Six methods for nginx optimization

1. Optimize Nginx concurrency [root@proxy ~]# ab ...

Six tips to increase web page loading speed

Secondly, the ranking of keywords is also related ...

Two methods of implementing automatic paging in Vue page printing

This article example shares the specific code of ...

How to implement parent-child component communication with Vue

Table of contents 1. Relationship between parent ...

How to use nginx to intercept specified URL requests through regular expressions

nginx server nginx is an excellent web server tha...

Two usages of iFrame tags in HTML

I have been working on a project recently - Budou...

Some points on using standard HTML codes in web page creation

The most common mistake made by many website desi...