Kako da instaliram MySQL servis

Radomi Mihajlovic

Zainteresovan član
Poruka
106
Vec duze se mucim oko instaliranja i startovanja MySQL servisa iz mog programa koji sam uradio u VS2015, sa MySQL 5.7.21, evo dela programa. Molim za pomoc.
private void proveri_da_li_postoji_RisServis()

private void proveri_da_li_postoji_RisServis()​

{​

serviceExists = ServiceController.GetServices().All(s => s.Status.Equals("RisServis"));​

//serviceExists = ServiceController.GetServices().All(s => s.Equals("RisServis"));​

if(serviceExists == true)​

{​

wpostoji_RisServis = "D";​

Process mysqlCloseCMD = new Process();​

mysqlCloseCMD.StartInfo.FileName = appPath + "\\MySQL\\bin\\mysqlad.exe -u root shutdown";​

mysqlCloseCMD.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;​

}​

else​

{​

wpostoji_RisServis = "N";​

}​

}​

private void instaliraj_RisServis()​

{​

//serviceExists = ServiceController.GetServices().Any(s => s.ServiceName == "RisServis");​

//if(!serviceExists)​

MessageBox.Show("POKUSAVAM DA INSTALIRAM RISSERVIS IZ INSTALIRAJ MySQL SA PUTA " + appPath);​

try​

{​

ServiceProcessInstaller ProcesServiceInstaller = new ServiceProcessInstaller();​

ProcesServiceInstaller.Account = ServiceAccount.LocalService;​

ProcesServiceInstaller.Username = "root";​

ProcesServiceInstaller.Password = "xxxxxxxx";​

ServiceInstaller ServiceInstallerObj = new ServiceInstaller();​

InstallContext Context = new System.Configuration.Install.InstallContext();​

path = String.Format(appPath + "\\MySQL\\bin\\mysqld --install --local-services RisServis --defaults-file=" + appPath + "\\MySQL\\Data\\my.ini");​

String[] cmdline = { path };​

Context = new InstallContext("", cmdline);​

ServiceInstallerObj.Context = Context;​

ServiceInstallerObj.DisplayName = "RisServis";​

ServiceInstallerObj.Description = "RisServis";​

ServiceInstallerObj.ServiceName = "RisServis";​

ServiceInstallerObj.StartType = ServiceStartMode.Automatic;​

ServiceInstallerObj.Parent = ProcesServiceInstaller;​

ServiceInstallerObj.DelayedAutoStart = true;​

System.Collections.Specialized.ListDictionary state = new System.Collections.Specialized.ListDictionary();​

ServiceInstallerObj.Install(state);​

winstaliran_RisServis = "D";​

MessageBox.Show("INSTALIRAO SAM RISSERVIS IZ INSTALIRAJ MySQL SA PUTA " + appPath);​

}​

catch(Exception x)​

{​

winstaliran_RisServis = "N";​

MessageBox.Show("NISAM INSTALIRAO SAM RISSERVIS IZ INSTALIRAJ MySQL SA PUTA " + appPath);​

}​

}​

 
Stavi pod code tag, nepregledno je. Sta ti ovde ne radi?
Ne mogu da instaliram RisServis kao deo windows servisa iz c# programa. Uspevam da instaliram iz comande linije iz cmd : mysqld --install --local-services RisServis. Kao da mi je potrebna neka dozvola. Dodao sam i --skip-secure-auth --force u path = String.Format(appPath mada se ovde to ne vidi.
Posle instaliranja RisServisa iz cmd kada postoji servis u windows servisu u delu programa (private void proveri_da_li_postoji_RisServis()) javlja mi da ne postoji RisServis.
Hvala
 

Back
Top