系统找不到启动mysql服务期间指定的文件 [英] The system cannot find the file specified during start mysql service

查看:279
本文介绍了系统找不到启动mysql服务期间指定的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试安装并启动MySQL服务以运行我的项目。



1-我下载了MySQL服务器5.7.17并将其配置为本教程:在Windows 10上手动安装和配置MySQL 5.7



2-我复制了MySQL文件夹并将其放在我的项目文件夹中(MyProject\bin\Debug \ mysql )



3-使用此代码以自定义名称安装和启动MySQL服务。

I try to install and start MySQL service to run with my project.

1- I downloaded MySQL server 5.7.17 and configured it to as this tutorial : Manually Installing and Configuring MySQL 5.7 on Windows 10

2- i copied the MySQL Folder and put it inside my project folder (MyProject\bin\Debug\mysql)

3- using this code to install and start MySQL Service with custom name.

var serviceExists = ServiceController.GetServices().Any(s => s.ServiceName == "mysqlTests");
            if (!serviceExists)
            {
                ServiceProcessInstaller ProcesServiceInstaller = new ServiceProcessInstaller();
                ProcesServiceInstaller.Account = ServiceAccount.LocalSystem;
                ProcesServiceInstaller.Username = null;
                ProcesServiceInstaller.Password = null;

                ServiceInstaller ServiceInstallerObj = new ServiceInstaller();
                InstallContext Context = new System.Configuration.Install.InstallContext();
                String path = String.Format("/assemblypath={0}", "mysql/bin/mysqld.exe");
                String[] cmdline = { path };

                Context = new InstallContext("", cmdline);
                ServiceInstallerObj.Context = Context;
                ServiceInstallerObj.DisplayName = "mysqlTests";
                ServiceInstallerObj.Description = "MySQL";
                ServiceInstallerObj.ServiceName = "mysqlTests";
                ServiceInstallerObj.StartType = ServiceStartMode.Automatic;
                ServiceInstallerObj.Parent = ProcesServiceInstaller;

                System.Collections.Specialized.ListDictionary state = new System.Collections.Specialized.ListDictionary();
                ServiceInstallerObj.Install(state);

            }

            ServiceController controller = new ServiceController();
            controller.ServiceName = "mysqlTests";
            if (controller.Status == ServiceControllerStatus.Stopped)
            {
                // Start the service
                controller.Start();
            }



i认为服务安装成功但出现此错误:$ exception {无法在计算机上启动服务mysqlTests'。'。}} System.InvalidOperationException Win32Exception :系统找不到指定的文件



作为附件图片:似乎安装了服务名称





更新:我更新代码:


i think the service installed successfully but this error appear : $exception {"Cannot start service mysqlTests on computer '.'."} System.InvalidOperationException Win32Exception: The system cannot find the file specified

as the attachment image: the service name seem to be installed


UPDATE:i update the code :

string appPath = Path.GetDirectoryName(Application.ExecutablePath);
 String path = String.Format("/assemblypath={0}", appPath + @"\mysql\bin\mysqld");



错误:

System.InvalidOperationException:'无法在计算机上启动服务mysqlTests'。'。'

Win32Exception:服务没有响应启动或控制请求及时的时尚



我的尝试:



我试过使用以下命令手动安装服务:




the error :
System.InvalidOperationException: 'Cannot start service mysqlTests on computer '.'.'
Win32Exception: The service did not respond to the start or control request in a timely fashion

What I have tried:

I tried to install the service manually with the command :

mysqld --install mysqlTests



服务成功安装。



并成功启动




the Service successfully installed.

and successfully start

E:\MyProject\bin\Debug\mysql\bin>net start mysqlTests





我不知道我能做些什么使我的代码安装并成功启动MySQL服务



I don't know what I can do to make my code install and start MySQL service successfully

推荐答案

exception {无法在计算机上启动服务mysqlTests'。'。}} System.InvalidOper ationException Win32Exception:系统找不到指定的文件



作为附件图片:服务名称似乎已安装





更新:我更新代码:

exception {"Cannot start service mysqlTests on computer '.'."} System.InvalidOperationException Win32Exception: The system cannot find the file specified

as the attachment image: the service name seem to be installed


UPDATE:i update the code :
string appPath = Path.GetDirectoryName(Application.ExecutablePath);
 String path = String.Format("/assemblypath={0}", appPath + @"\mysql\bin\mysqld");



错误:

System.InvalidOperationException:'无法在计算机上启动服务mysqlTests'。'。'

Win32Exception:服务没有响应启动或控制请求及时的时尚



我的尝试:



我试过使用以下命令手动安装服务:




the error :
System.InvalidOperationException: 'Cannot start service mysqlTests on computer '.'.'
Win32Exception: The service did not respond to the start or control request in a timely fashion

What I have tried:

I tried to install the service manually with the command :

mysqld --install mysqlTests



服务成功安装。



并成功启动




the Service successfully installed.

and successfully start

E:\MyProject\bin\Debug\mysql\bin>net start mysqlTests





我不知道我能做些什么使我的代码安装并成功启动MySQL服务



I don't know what I can do to make my code install and start MySQL service successfully


您没有遵循最佳实践。您的应用程序的安装程序应该运行MySQL安装程序。然后,如果您的代码尚未运行,您的代码就可以启动该服务,但在我看来,如果您正确运行MySQL安装程序,该服务确实应该正在运行。
You are not following best practice. Your app's installer should run the MySQL installer. Your code can then start the service if it's not already running, but it seems to me that the service should indeed be running if you run the MySQL installer correctly.


这篇关于系统找不到启动mysql服务期间指定的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆