Service cannot be started after mysql installation

1.1 Preface

  I've been really unlucky recently, and installing mysql can greet all the problems... But this is also a valuable experience, and I have to summarize it well. After all, I don't know if I will encounter it again in the future. . If there are netizens who are unlucky like me, but they are lucky enough to see my article and really solve the problem, then I will be happy.

1.2 My unlucky process

  The company's new computer has arrived. For personal reasons, I want to install mysql on this machine to facilitate my work. I know that there are two ways to install mysql, one is to automatically install the msi installation package, and the other is to configure the relevant files for installation after decompressing the zip package. At the beginning, I chose the msi automatic installation without thinking. As a result, various errors were reported, and the installation could not be successful. The various search materials were still unsolved. There was no way to download the zip package for decompression, configuration and installation. After mysql was installed, I just wanted to put my mind down, but found that the mysql service could not be started, and then after a toss, the service started, and suddenly there was a problem of not being able to connect to the database. It is another kind of data review, and finally all the problems are solved, and the database access is successful! ! ! I am drunk even if I can meet such a wonderful series, so I have to record the solution process of the main problem as detailed as possible. Looking back, you can also know how much water you used to be, and then you can know your level of progress, or a sense of accomplishment. Without further ado, let's get to the point. (PS: If you encounter problems during the installation process, please refer to: http://www.cnblogs.com/tanshaoxiaoji/p/mysql_install_type.html )

1.3 Enter the topic, service startup solution

  1. Find the configuration file my.ini in the mysql installation directory, that is, the root directory (if it is my.default.ini, change it to my.ini), and then move my.ini to the root directory of the bin folder; 
  2. Windows+R, enter cmd to enter the command line mode, enter the command cd D:\MySQL\mysql-5.7.19-winx64\bin to enter the bin root directory of mysql; (Note: If this command cannot be executed successfully, execute it first D:, after successfully switching the directory, execute cd MySQL\mysql-5.7.19-winx64\bin)
  3. After successfully entering the bin directory, execute the command mysqld --initialize --user=mysql --console

  4. Be sure to save the random temporary password generated as a result of the execution of the previous step, sure! (If you can't copy it, you can try this, right-click to select all, then click near the random temporary password, then drag the mouse to select the random temporary password, press Ctrl+C, don't doubt yourself, try in the txt text Press Ctrl+V to try, is it copied? Haha)

  5.  Then execute the command mysqld --install (also believe in yourself, execute net start mysql (or Windows+R, enter services.msc, find MYSQL and click to start and try) to see if it can be started), even if the startup is successful, don't be in a hurry to be happy first, It's not over yet, so be patient and look down 

  6.  Then enter the command mysql -u root -p and press Enter, enter the temporary random password you just copied *********, you will feel that the stone in your heart has finally landed (is it?)

  7.  The last step is to modify the expired password. At that time, I used mysqladmin -u root -p password 123456 to check the information. The result was an error, and then taught me to update mysql.user set password=PASSWORD('the password I want to set') where User =' root';, the result is still an error, do it! ! Finally found it (moved!). that is!

       ALTER USER 'root'@'localhost' IDENTIFIED BY ' 新密码' PASSWORD EXPIRE NEVER;-- The password never expires, if NEVER is removed, the 
command
flush privileges will be executed with expiration time;
1.4 Conclusion! ! !
  
In a short article, it was written from 11:00 p.m. to 00:30 p.m., but I was still very happy and able to summarize the problem. I hope it will be helpful to everyone, thank you!
 
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325204237&siteId=291194637