Restart mysql within php browser, permissions issue?

本秂侑毒 提交于 2019-12-07 08:22:20

问题


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

回答1:


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



来源:https://stackoverflow.com/questions/10588636/restart-mysql-within-php-browser-permissions-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!