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:
|
>>: Install centos7 virtual machine on win10
1. Function : Allows the parent component to inse...
Sttty is a common command for changing and printi...
There are two ways to deploy Angular projects wit...
This article uses examples to illustrate the prin...
By default, MySQL can accept the insertion of 0 v...
<br />The most common mistake made by many w...
The reason is simple: In HTML documents, multiple ...
Table of contents 1. Analysis of key source code ...
You may often see some HTML with data attributes. ...
As shown below: The test command determines wheth...
The difference between http and https is For some...
The so-called container actually creates a readab...
1. Introduction to Docker Docker is developed in ...
1. Add the isolation marker: ip netns add fd 2. P...
Table of contents Preface Creating a component li...