title: Stopping MySQL database server: mysqld failed
body: <p>Basically, when i want to sop mysql server service :</p>
  
  <pre><code>sudo /etc/init.d/mysql stop
  </code></pre>
  
  <p>i'm getting this error message:</p>
  
  <pre><code>[FAIL] Stopping MySQL database server: mysqld failed!
  </code></pre>
  
  <p>After some research to solve this i followed this to-do step:</p>
  
  <pre><code>sudo cat /etc/mysql/debian.cnf
  </code></pre>
  
  <p>Which gives me something like :</p>
  
  <pre><code># Automatically generated for Debian scripts. DO NOT TOUCH!
  [client]
  host     = localhost
  user     = debian-sys-maint
  password = xXxXxXxXxXxX
  socket   = /var/run/mysqld/mysqld.sock
  [mysql_upgrade]
  host     = localhost
  user     = debian-sys-maint
  password = xXxXxXxXxXxX
  socket   = /var/run/mysqld/mysqld.sock
  basedir  = /usr
  </code></pre>
  
  <p>Then i did</p>
  
  <pre><code>mysql -u root -p
  </code></pre>
  
  <p>And finally </p>
  
  <pre><code>GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY 'xXxXxXxXxXxX' WITH GRANT OPTION;
  </code></pre>
  
  <p>This should have work but i'm getting another error here :</p>
  
  <pre><code>ERROR 1045 (28000): Access denied for user 'root'@'%' (using password: NO)
  </code></pre>
  
  <p>Actually, i made some mistake before that, running this: DELETE * FROM mysq.user WHERE host = 'localhost'. </p>
  
  <p>I now have only one user left, and it seems he doesn't have the permission to GRANT anything:</p>
  
  <pre><code>mysql&gt; select Host, user from mysql.user;
  +------------------+--------------+
  | Host             | user         |
  +------------------+--------------+
  | %                | root         |
  +------------------+--------------+
  1 rows in set (0.00 sec
  </code></pre>
  
  <p>Is there a way to handle this ? Actually i just want to remove mysql server and install it again from scratch. But it will fails removing until i can first stop mysqld:</p>
  
  <p>~$ ps aux | grep mysql | grep -v grep</p>
  
  <pre><code>root      8252  0.0  0.0  12720  2776 pts/1    Ss+  09:42   0:00 /usr/bin/dpkg --status-fd 17 --configure mysql-common:all libmysqlclient18:amd64 libdbd-mysql-perl:amd64 mysql-client-5.5:amd64 mysql-server-core-5.5:amd64 mysql-server-5.5:amd64
  root      8255  0.0  0.3  61372 14180 pts/1    S+   09:42   0:00 /usr/bin/perl -w /usr/share/debconf/frontend /var/lib/dpkg/info/mysql-server-5.5.postinst configure 5.5.38-0+wheezy1
  root      8265  0.0  0.0  10900  1676 pts/1    S+   09:42   0:00 /bin/bash /var/lib/dpkg/info/mysql-server-5.5.postinst configure 5.5.38-0+wheezy1
  root      8579  0.0  0.0  21656  2928 pts/1    S+   09:50   0:00 whiptail --backtitle Configuration package tools --title mysql-server-5.5 Configuration --output-fd 11 --nocancel --msgbox Impossible to change « root » password of MySQL 13 198
  root     30566  0.0  0.0   4180   728 ?        S    00:41   0:00 /bin/sh /usr/bin/mysqld_safe
  mysql    30882  0.0  1.9 368500 77668 ?        Sl   00:41   0:16 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306
  root     30883  0.0  0.0   5588   696 ?        S    00:41   0:00 logger -t mysqld -p daemon.error
  </code></pre>
  
  <p>i already tried it with :</p>
  
  <pre><code>sudo apt-get remove mysql-server mysql-client mysql-common
  sudo apt-get purge mysql-server mysql-client mysql-common
  sudo apt-get autoremove
  sudo apt-get remove --purge mysql\*
  </code></pre>
  
  <p>And it seems it fails because it cannot stop mysqld in the first place</p>