通过使用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();
}