title: ubuntu - mysql start and restart issue on ubuntu 16.04 server
body: <p>i installed mysql 5.7 but then found out I need mysql 5.6 so i deleted all mysql related packages with </p>
  
  <pre><code>apt-get remove --purge mysql*
  </code></pre>
  
  <p>so it gotten removed. then i issued:</p>
  
  <pre><code>apt-get install mysql-server-5.6 mysql-client-5.6
  </code></pre>
  
  <p>so the mentioned packages gotten installed.
  but its not starting using <code>systemctl start mysql</code> or <code>service mysql start</code> or even restart. the result is this:</p>
  
  <pre><code>service mysql restart
  or
  service mysql start
  or
  systemctl restart mysql
  or
  systemctl start mysql
  </code></pre>
  
  <p>returns:</p>
  
  <pre><code>Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
  </code></pre>
  
  <p>but</p>
  
  <pre><code>systemctl status mysql
  </code></pre>
  
  <p>returns</p>
  
  <pre><code> mysql.service - LSB: Start and stop the mysql database server daemon
     Loaded: loaded (/etc/init.d/mysql; bad; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2017-04-10 13:24:00 EDT; 29s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 15820 ExecStart=/etc/init.d/mysql start (code=exited, status=1/FAILURE)
   Main PID: 1323 (code=exited, status=0/SUCCESS)
  
  Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Compressed tables use zlib 1.2.8
  Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Using Linux native AIO
  Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Using CPU crc32 instructions
  Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Initializing buffer pool, size = 128.0M
  Apr 10 13:23:30 server mysqld[15926]: 2017-04-10 13:23:30 15925 [Note] InnoDB: Completed initialization of buffer pool
  Apr 10 13:24:00 server mysql[15820]:    ...fail!
  Apr 10 13:24:00 server systemd[1]: mysql.service: Control process exited, code=exited status=1
  Apr 10 13:24:00 server systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
  Apr 10 13:24:00 server systemd[1]: mysql.service: Unit entered failed state.
  Apr 10 13:24:00 server systemd[1]: mysql.service: Failed with result 'exit-code'.
  </code></pre>
  
  <p>what is <code>Failed to start LSB: Start and stop the mysql database server daemon.</code>
  before installing 5.6 the 5.7 version was working fine but now its like this.</p>
  
  <p>the <code>/var/log/mysql/errors.log</code> is empty and these are the <code>/var/log/syslog</code> last lines</p>
  
  <pre><code>Apr 10 13:23:30 server mysqld: 2017-04-10 13:23:30 15925 [Note] InnoDB: Completed initialization of buffer pool
  Apr 10 13:23:30 server mysqld_safe: mysqld from pid file /var/lib/mysql/server.pid ended
  Apr 10 13:24:00 server /etc/init.d/mysql[16277]: 0 processes alive and '/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf ping' resulted in
  Apr 10 13:24:00 server /etc/init.d/mysql[16277]: #007/usr/bin/mysqladmin: connect to server at 'localhost' failed
  Apr 10 13:24:00 server /etc/init.d/mysql[16277]: error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
  Apr 10 13:24:00 server /etc/init.d/mysql[16277]: Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
  Apr 10 13:24:00 server /etc/init.d/mysql[16277]:
  Apr 10 13:24:00 server mysql[15820]:    ...fail!
  Apr 10 13:24:00 server systemd[1]: mysql.service: Control process exited, code=exited status=1
  Apr 10 13:24:00 server systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
  Apr 10 13:24:00 server systemd[1]: mysql.service: Unit entered failed state.
  Apr 10 13:24:00 server systemd[1]: mysql.service: Failed with result 'exit-code'.
  </code></pre>
  
  <p>output of <code>mysqld_safe</code> </p>
  
  <pre><code>170410 13:33:28 mysqld_safe Logging to syslog.
  170410 13:33:28 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
  170410 13:33:28 mysqld_safe mysqld from pid file /var/lib/mysql/server.pid ended
  </code></pre>
  
  <p>and this is my <code>/etc/mysql/my.cnf</code> and there is no <code>/etc/my.cnf</code></p>
  
  <pre><code>#
  # The MySQL database server configuration file.
  #
  # You can copy this to one of:
  # - "/etc/mysql/my.cnf" to set global options,
  # - "~/.my.cnf" to set user-specific options.
  #
  # One can use all long options that the program supports.
  # Run program with --help to get a list of available options and with
  # --print-defaults to see which it would actually understand and use.
  #
  # For explanations see
  # http://dev.mysql.com/doc/mysql/en/server-system-variables.html
  
  # This will be passed to all mysql clients
  # It has been reported that passwords should be enclosed with ticks/quotes
  # escpecially if they contain "#" chars...
  # Remember to edit /etc/mysql/debian.cnf when changing the socket location.
  
  # Here is entries for some specific programs
  # The following values assume you have at least 32M ram
  
  !includedir /etc/mysql/conf.d/
  </code></pre>