MySQL "cannot create Windows Service for MySQL. Error: 0" Install and delete Windows Services [go]

Source: Internet
Author: User

InstallMySQLThe system prompts: Cannot create windows service for mysql. error: 0.

The reason is that the old mysql service exists in the system. The solution is as follows:

To permanently delete the old mysql service, you must run the following command on the command line with the administrative permission:
C: \> SC delete mysql
[SC] DeleteService SUCCESS

When installing the service, if a similar situation occurs, check whether the service is a legacy service program, solution, delete the old service, and install the new service.

/*! Cteate a table test ;*/
Drop table if exists 'baninfo _ special ';
Create table 'baninfo _ special '(
'Id' int (11) not null auto_increment,
'Special _ id' int (11) not null,
'Port' int (11 ),
'Time' timestamp,
'Src _ ip' varchar (64) default '',
'Act 'int (11 ),
'Baninfo _ specialname 'varchar (64) default '',
'Password' varchar (64) default '',
Primary Key ('id ')
) Engine = MyISAM default charset = 'utf8 ';

Appendix, service operations:

To delete a system service, use SC delete
[Service name]. For example, to DELETE the messager service, enter SC DELETE MESSAGER.
SC uses the following syntax:
1. SC [Servername] command Servicename [Optionname = Optionvalue]
2. SC [command]
The first syntax uses SC and the second syntax displays help.
The following describes the parameters.
Servername
Optional: You can use double slashes, such as \ myserver or \ 192.168.0.1 to operate remote computers. If you operate on a local computer
You do not need to add any parameters.
Command
The following lists the SC commands that can be used.
Config ---- change the configuration of a service. (Long term)
Continue -- send a request for continuous control to a service.
Control ---- send a control to a service.
Create ---- create a service. (Add to Registry)
Delete ---- delete a service. (Delete from Registry)
EnumDepend -- lists the service subordination.
GetDisplayName -- get the display name of a service.
GetKeyName -- get the service key name of a service.
Interrogate -- sends a query control request to a service.
Pause ---- send a suspend control request to a service.
Qc ---- ask about the configuration of a service.
Query ---- query the status of a service. You can also list the status types of the service.
Start ---- start a service.
Stop ---- requests a service to send a stop request.
Servicename
Name specified for the service key in the registry. Note that this name is different from the display name (this name can be set using net start and service control.
And SC uses the service key name to identify the service.
Optionname
The optionname and optionvalue parameters allow you to specify the name and value of the operation command parameters. Note that this is important in terms of the operation name and
There is no space between them. I don't know the result at first .................., For example, start = optionvalue is very important.
Optionvalue can be 0, 1, or more operation parameter names and value pairs.
If you want to view the optionvalue available for each command, you can use the SC command format. This will provide you with detailed help.
Optionvalue
Specify a value for the parameter name of optionname. The range of valid values is usually limited to the optionname parameter. Use
SC command to query each command.
Comments
Many Commands require administrator permissions, so I would like to say that you should be the administrator when operating these commands. Haha!
When you click "SC .exe" without any commands, SC .exe displays help information and available commands. When you type SC followed by the command name, you can
To a detailed list of commands. For example, you can enter SC create to obtain a list related to create.
Except for one command, SC query exports the status of all services and drivers currently running in the system.
When you use the start command, you can pass some parameters (arguments) to the main function of the service, but not to the main function of the service process.
SC create
This command can be used to create an entry in the Registry and service control management database.
Syntax 1
SC [servername] create Servicename [Optionname = Optionvalue]
The servername, servicename, optionname, and optionvalue here are the same as those above. Here we will detail
Optionname and optionvalue.
Optionname -- optionvalue
Description
Type = ---- own, share, interact, kernel, filesys
About the service creation type, the option value includes the type used by the driver. The default value is share.
Start = ---- boot, system, auto, demand, Disabled
About the Service Startup type, the option value includes the type used by the driver. The default value is demand (Manual ).
Error = ---- normal, severe, critical, ignore
The default value is normal.
Binpath = -- (string)
The path name of the Service binary file. There is no default value here. This string must be set.
Group = ---- (string)
The group to which this service belongs. The list of this group is saved under servicegrouporder in the registry. The default value is nothing.
Tag = ---- (string)
If this string is set to yes, SC can get a tagid from createservice call. However, SC does not display this label
It makes little sense to use this. The default value is nothing.
Depend = ---- (space separated string) string with spaces.
The name or group of the service that must be started before the service starts.
OBJ = ---- (string)
The name used for account running. The default value is LocalSystem.
Displayname = -- (string)
A string used to identify each service in the user interface program.
Password = -- (string)
A password, which is used if an account is different from the LocalSystem account.
Optionvalue
The Value List of the Optionname parameter. Refer to optionname. When we input a string, If we input an empty reference, this means
An empty string will be imported.
Comments
The SC CREATE command performs the operations of the CreateService API
Function.
Run the SC create command to execute the CreateService API function. For details, see CreateService.
Example 1
The following example shows how to register a registry created for a service named "NewService" on a computer named \ myserver.
SC \ myserver create NewService binpath = c: \ winnt \ system32 \ NewServ.exe
By default, this service creates a win32_assist_process startup mode using SERVICE_DEMAND_START. This will not have any subordination
Will also run according to the localsystem security up-down relationship.
Example 2
In the following example, a service is created on a local computer and runs on its own process automatically. It
From the TDI group and NetBios service. Note that you must add a space reference to the slave.
SC create NewService binpath = c: \ winnt \ system32 \ NewServ.exe type = own
Start = auto depend = "+ TDI Netbios"
Example 3
Service developers can temporarily change the binary path (image path) to run the service in the context of the kernel debugger. Lower
In this example, we can see how to change the service configuration.
SC config NewService binpath = "ntsd-d c: \ winnt \ system32 \ Newserv.exe"
In this example, the service controller calls ntsd.exe to use the following parameter string:
"-D c: \ nt \ system32 \ NewServ.exe"
When the system is installed with newserv.exe, ntsd will interrupt the debugger, so the breakpoint can be set in the service code.
SC QC
This SC QC "query configuration" command can list the configuration information of a service and the QUERY_SERVICE_CONFIG structure.
Syntax 1
SC [Servername] qc Servicename [Buffersize]
Parameters
Servername and servicename have already been introduced.
Buffersize, which can be used to list the buffer size.
Comments
The SC QC command displays the content of the QUERY_SERVICE_CONFIG structure.
The following is the region of QUERY_SERVICE_CONFIG.
TYPE ------ dwServiceType
START_TYPE ---- dwStartType
ERROR_CONTROL ---- dwErrorControl
BINARY_PATH_NAME -- lpBinaryPathName
LOAD_ORDER_GROUP -- lpLoadOrderGroup
TAG ------ dwTagId
DISPLAY_NAME ---- lpDisplayName
DEPENDENCIES ---- lpDependencies
SERVICE_START_NAME -- lpServiceStartName
Example 1
The following example shows the configuration of the "NewService" service created in the preceding example:
SC \ myserver qc NewService
SC displays the following information:
SERVICE_NAME: NewService
TYPE: 20 win32_0000_process
START_TYPE: 3 DEMAND_START
ERROR_CONTROL: 1 NORMAL
BINARY_PATH_NAME: c: \ winnt \ system32 \ NewServ.exe
LOAD_ORDER_GROUP:
TAG: 0
DISPLAY_NAME: NewService
DEPENDENCIES:
SERVICE_START_NAME: LocalSystem
NewService can share a process with other services. But it is not automatically started. The binary file name is newserv.exe. This service
It does not rely on other services and runs in the security context of lcoalsystem. These are basic responses to QueryServiceStatus.
Back, if you need more details, you can look at the API function file.
SC QUERY
The SC query command can obtain service information.
Syntax:
SC [servername] query {servicename | optionname = optionvalue ...}
Parameters:
Servername, servicename, optionname, and optionvalue are not interpreted. Let's just talk about the value provided by this command.
Optionname -- optionvalue
Description
Type = ---- driver, service, all
Lists the service types. The default value is service.
State = ---- active, inactive, all
Lists the status of a Service. The default value is active.
Bufsize = -- (numeric value)
List the buffer size. The default value is 1024 bytes.
Ri = ---- (numeric value)
However, when listing, the number of the Restoration pointer is 0 by default.
Optionvalue
Same as above.
Comments
The SC QUERY command displays the SERVICE_STATUS structure.
The following figure shows the SERVICE_STATUS structure:
TYPE ------ dwServiceType
STATE ------ dwCurrentState, dwControlsAccepted
WIN32_EXIT_CODE ---- dwWin32ExitCode
SERVICE_EXIT_CODE -- dwServiceSpecificExitCode
CHECKPOINT ---- dwCheckPoint
WAIT_HINT ---- dwWaitHint
After the computer is started, use SC
The QUERY command will tell you whether or not it is not an attempt to start the service. If the service is successfully started, the WIN32_EXIT_CODE interval will contain a value of 0. When the attempt fails, it realizes that the service cannot be started, this interval also provides an exit code for the service.

Example
To query the "newservice" service status, type:
SC query newservice
The following information is displayed:
SERVICE_NAME: newservice
Type: 20 win32_0000_process
State: 1 stopped
(Not_stoppable, not_pausable, ignores_shutdown)
Win32_exit_code: 1077 (0x435)
Service_exit_code: 0 (0x0)
Checkpoint: 0x0
Wait_hint: 0x0
Note: there is an exit code for this service. Even if this service department is not running, type net helpmsg 1077 and you will get a description of the error 1077:
The service has not been started yet.
So here I want to say that we hope you can use net helpmsg, which will be of great help to your learning.
The following describes the SC query command:
To list the status of the active service and driver, run the following command:
SC Query
To display the messenger service, run the following command:
SC query messenger
To list only the active drivers, run the following command:
SC Query type = driver
To list Win32 services, run the following command:
SC query type = service
To list all services and drivers, run the following command:
SC query state = all
Use a buffer of 50 bytes to list data. Use the following command:
SC query bufsize = 50
Use index = 14 to restore the list. Run the following command:
SC query ri = 14
To list all interactive services, run the following command:
SC query type = service type = interact

 

 

Run the SC command on the command line.
For details about the SC command, please view the help (SC /?), Here, we will only briefly introduce how to add system service functions.
Join Service:
SC create ServiceName binPath = path start = auto
(The space after the equal sign is required)
Delete service:
SC delete ServiceName
E. g
Add Tomcat to the System Service:
SC create Tomcat binPath = F: \ apache-tomcat \ bin \ startup. bat start = auto
Delete the Tomcat service:
SC delete Tomcat
SC description tomcat "provides end-to-end security between clients and servers on TCP/IP networks. If this service is disabled, clients and servers on the network

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.