the MySQL service on local computer started and th

2020-02-02 05:05发布

问题:

the MySQL service on local computer started and then stopped. Some services stop automatically if they are not in use by other services or programs.

Can anyone resolve this issue? Thanks.

回答1:

After installing it by mysqld --install. Try this mysqld --initialize. We got the same problem but it's now working.



回答2:

If using version 8 and you edit the my.ini I found that Notepad is putting 3 hex characters at the beginning of the my.ini file. EF BB BF. Deleting the 3 characters from the beginning of the file in a hex editor fixes the problem.

In version 8 they are accidentally putting Unicode characters in the ini file. This is causing Notepad to save the file with Byte order mark characters.

The following line in the file is the culprit "The line # range from 1 to 2^32 − 1. “Unique” means that each ID must be different." has 3 Unicode characters. This is causing notepad to append the byte order mark to the text file.



回答3:

Also remember to give NETWORK SERVICE permission to the folder:

  1. Right-click Data folder
  2. Select Properties
  3. Select Security tab
  4. Click Advanced
  5. Click Change Permissions...
  6. Click Add...
  7. Type NETWORK SERVICE
  8. Click Check Names
  9. Click OK
  10. Select Full Control
  11. Click OK – four times
  12. Start MySQL service


回答4:

In my case, I tried to open a DOS prompt and go to the MySQL bin\ directory and issue the below command:

mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server 5.0\my.ini" --standalone --console

And it shows me I was missing the "C:\Program Files\MySQL\MySQL Server 5.0\Uploads" folder; I built one and problem solved.



回答5:

  1. Open Service
  2. Right click on MYSQL service
  3. select Log on
  4. check local system account
  5. start service


回答6:

This may be because of changing lower_case_table_names after a server has been already initialized.

From the docs:

lower_case_table_names can only be configured when initializing the server. Changing the lower_case_table_names setting after the server is initialized is prohibited.

The solution to this problem is to set lower_case_table_names parameter at server installation as described in the following answer:

Can't set lower_case_table_names in MySQL 8.x on Windows 10



回答7:

Using Community 8.0.17, upgraded from 8.0.16

There may be a more secure way of doing this, but since I'm just running a dev box:

  1. navigate to the \data folder
  2. make SURE the \data folder is EMPTY. If files exist the --initialize option will fail
  3. give SYSTEM Full Control permissions on the \data folder
  4. go back to your command prompt
  5. run mysqld --initialize

you should see all of the required data file structures in the data folder now. If they are not created, the mysqld process has contention or improper security to write into the folder correctly.

Now start your named service in whatever fashion you want (SC/NET/service.msc, etc)

Assuming all of the files were created properly by --initialize the service will start.



回答8:

Rename or delete the folder under,

C:\ProgramData\MySQL\MySQL Server 5.7

folder name change as per your MYSQL version number.



回答9:

This error happened in my case when secure-file-priv was pointing to unexistent folder, make sure it exists and readable.

The line of code example in my.ini: secure-file-priv="D:/MySQL/uploads"



回答10:

Nothing was working for me but then I checked here. I ran that command qc sc mysql57 and copied the value of BINARY_PATH_NAME from it. After that I checked this and changed the value of lower_case_table_names from 0 to 2 in my.ini file. Then in the command prompt, I ran this command - << BINARY_PATH_NAME >> --install-manual. After that, I started the MySQL57 service and it worked.



回答11:

In my case, mysqld was starting and stopping with no error message. I needed to open command prompt using "Run as Administrator", and then run mysqld.

I am only doing this for temporary development. I would not recommend running MySQL as an administrator in any case.

This was the final step after the above troubleshooting.



回答12:

mysqld --initialize

Run the above after the install command. Then try to start the service - that should work.



回答13:

Search for services.msc and look up through your services that are running if there is a mysql service running already other than the one you want to run (it could be xampp or wamp) or another service (for example Skype) using the same port as mysql and stop the service so you can run your mysql service.



回答14:

I had this issue after my database was working fine for long time. It turned out it was some data corruption.

In the error log I had:

2017-02-07T10:11:42.270567Z 0 [ERROR] InnoDB: Ignoring the redo log due to missing MLOG_CHECKPOINT between the checkpoint 44002250712 and the end 44002250240.
2017-02-07T10:11:42.270606Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2017-02-07T10:11:42.577436Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2017-02-07T10:11:42.577470Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2017-02-07T10:11:42.577484Z 0 [ERROR] Failed to initialize plugins.
2017-02-07T10:11:42.577488Z 0 [ERROR] Aborting

Then I had to delete the 2 ib_logfile* files, and it restarted again.



回答15:

You also might have accidentally added some wrong text in my.ini file. Make sure no invalid character is added at the beginning on the file.



回答16:

The same problem happened with me also, noting worked... I first deleted the service (in my case MySQL80 and MySQL) by command:

sc delete MySQL80
sc delete MySql

and then reinstalled MySQL. Mine was MySQL 8.0. And then everything was back to normal.



回答17:

If you have changed data directory (the path to the database root in my.ini) to an external hard drive, make sure that the hard drive is connected.