在C#中通过命令提示符更改phpmyadmin root密码

时间:2015-02-07 10:46:04

标签: c# mysql cmd phpmyadmin root

通过使用c#在cmd中执行命令来重置phpmyadmin root密码。我尝试了很多方法但失败了。这是我的代码

      public void setmysqlpassword()
    {

ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe");
processStartInfo.WorkingDirectory = @"c:\xampp\mysql\bin"; 
processStartInfo.RedirectStandardInput = true;
processStartInfo.RedirectStandardOutput = true;
processStartInfo.UseShellExecute = false;

Process process = Process.Start(processStartInfo);

if (process != null)
{

    process.StandardInput.WriteLine("mysql.exe -h localhost -u root -p");

      process.StandardInput.WriteLine("SET PASSWORD FOR root@localhost=PASSWORD('newpassword');");


    process.StandardInput.Close(); hanging on ReadToEnd()

    string outputString = process.StandardOutput.ReadToEnd();

}

0 个答案:

没有答案