4

I would like to create a button on my website that restarts mysql (I realize this is really bad news). I am using ec2 which has really strict user permissions.

This is my php code, but it's not restarting the session.

<?php
if(isset($_POST['mysql'])){
    exec("sudo /etc/init.d/mysqld restart");
}
?>

<form method="POST" action="">
<input type="submit" value="mysql" name="mysql">
</form>

This is my suders file ...

Cmnd_Alias RESTART_MYSQL  = /etc/init.d/mysqld restart
mysql ALL =NOPASSWD: RESTART_MYSQL

This doesn't work either...

Cmnd_Alias RESTART_MYSQL  = /etc/init.d/mysqld restart
apache ALL =NOPASSWD: RESTART_MYSQL
Marjeta
  • 1,111
  • 10
  • 26
FrankZappa
  • 94
  • 5

1 Answers1

1

When you run sudo, you need to enter your password. SO, you can't use sudo in a script.

Marjeta
  • 1,111
  • 10
  • 26