MYSQL service failed to start service did not report any errors

Today, I installed mysql5.7 in the Windows 10 64-bit environment in zip mode. At the last step, it was prompted that the mysql service could not be started.

The installation steps are as follows:

1. Configure environment variables

My Computer -> Properties -> Advanced -> Environment Variables -> path

如:C:\Program Files\MySQL\MySQL Server 5.6\bin 

Note that it is appending, not overwriting

2. Modify my-default.ini

Modify or add configuration there: 

[mysqld] 

basedir=C:\Program Files\MySQL\MySQL Server 5.6 (the directory where mysql is located) 

datadir=C:\Program Files\MySQL\MySQL Server 5.6\data (the directory where mysql is located\data)

3. Run cmd as administrator (right click the start button in the lower left corner of win10 and select run cmd as administrator)

Run cmd as an administrator (be sure to run it as an administrator, otherwise the permissions are not enough),

Enter: cd C:\Program Files\MySQL\MySQL Server 5.6\bin to enter the bin folder of mysql (regardless of whether the environment variable has been configured, also enter the bin folder, otherwise the service will still report error 2 after starting the service)

Enter mysqld -install (if you don't run it as an administrator, you will get an error due to insufficient permissions: Install/Remove of the Service Denied!) 

Successful installation

4. Run mysqld --initialize (the problem with the title, if there is no init, the data directory does not exist, and naturally it cannot start successfully)

5. After the installation is successful, the service will be started. Continue to enter: net start mysql in cmd. The service starts successfully!

After the service starts successfully, you can log in, enter mysql -u root -p (the first login has no password, just press Enter), the login is successful!

 

Additional content:

When installing mysql 5.7 version, it is often encountered that mysql -u root -p cannot log in directly by pressing Enter. The reason is that version 5.7 automatically gave a random password during installation. For example, the linux system will give a command line prompt. You need to manually search for *.err in the mysql directory and open it in text form to see the following:

2016-11-13T07:42:53.922718Z 1 [Note] A temporary password is generated for root@localhost: e(%ADEovr1pr

 

After logging in for the first time, you need to modify the password of the root user. The modified command is as follows:

set password for root@localhost = password('new password')

 

Guess you like

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