MySQL 5.7 service fails to start

After installing MySQL 5.7 for a while, I suddenly failed to connect to the database one day. I found a tutorial on the Internet and said to go to the task manager service to find the MySQL service and start it. However, the dog beeped and there was no shadow of the MySQL service.

At this time, perform the following operations, remember! ! ! The following commands are run in the bin directory of your MySQL installation directory, and with administrator status :

1. Install the MySQL service

 

 

 

Then I went to the service to find MySQL, acridine! Really found, cowhide cowhide ,,,

 

 

 The right mouse button starts, and the operation is as fierce as the tiger, the result shows that it can't be started. ! !

2. After fighting on Google for more than half an hour, it was finally solved. Tutorial just found online (not solved):

    (1) Still in the bin directory of the MySQL installation directory, execute mysqld -initislize

    (2) Then execute net start mysql

   Of course, eggs

  

 

  After looking at the error message, I found that there is no data folder in the root directory of my MySQL installation, and I fought on Google and finally solved it.

  In mysql5.7 and above, there is no data directory by default, that is, there is no initialization service. You need to initialize mysql before you can start the service, otherwise it will report "the service did not report any errors" and the startup failed.

  The correct steps are:

   (1) First execute the mysqld --initialize-insecure (not set root password, it is recommended) command in the bin directory of mysql. The first time you execute this command will wait a little longer, and the console returns nothing . You can see that there will be an additional data folder under the root directory of mysql with a bunch of files in it.

           

 

          

 

          

 

 

   (2) Then execute the above two commands,      

         1) Still in the bin directory of the MySQL installation directory, execute mysqld -initislize

         2) Then execute net start mysql

        This time it succeeded!

          

 

 

 (3)

      1) mysql installation is complete, please enter "mysql -u root -p" happily, enter, but actually did not enter, there is a "ERROR 1045 Access denied for ,,,,,,,,,"

         

 

 

         The reason is that the new version of mysql has a password by default for security.

         Solution:

         The default installation of mysql will generate a password, and the password file is written directly in the log-error log file (in the 5.6 version it is placed in the root / .mysql_secret file, which is more concealed and may be at a loss if you are not familiar)

          After the installation of MySQL5.7, the first time it starts, it will produce a random password in the root directory, the file name is .mysql_secret

          You need to log in with a random password when logging in, and then change the password with the following command

          SET PASSWORD = PASSWORD('new password');

 

Guess you like

Origin www.cnblogs.com/laomahope/p/12676767.html