title: Restart MySql Server From The Browser Using PHP/Shell Script In Linux
body: <p>I want to restart mysql service on click of the button using php.</p>
  
  <p>I have developed application using php till now I tried below things and facing the problem</p>
  
  <pre><code>&lt;?php
  if ($_GET['run']) {
    # This code will run if ?run=true is set.
    var_dump(exec("sh rst.sh"));
    exit;
  }
  ?&gt;
  
  &lt;!-- This link will add ?run=true to your URL, myfilename.php?run=true --&gt;
  &lt;a href="?run=true"&gt;Click Me!&lt;/a&gt;
  </code></pre>
  
  <p>What I am  getting is:</p>
  
  <pre><code>string(55) "Restarting mysql (via systemctl): mysql.service failed!" 
  </code></pre>
  
  <p>rest.sh:</p>
  
  <pre><code>#!/bin/bash
  /etc/init.d/mysql restart
  </code></pre>
  
  <p>while executing above file from the commnad line it asks for the password.</p>
  
  <p>any help will be appreciated.</p>
  
  <p>Thanks</p>