MySQL not working after upgrade from 14.04 to 16.04

Solution 1:

we were also facing same issue after Upgarde from 14.04 to 16.04 Solved the problem by removing

myisam-recover = BACKUP

and

key_buffer = 16M

from my.cnf.

Then use

sudo service mysql start

to start the MySQL daemon again and

sudo apt-get -f install 

to recover your system packaging state.

I found this advicehere: https://bugs.launchpad.net/ubuntu/+source/mysql-5.7/+bug/1570673, you can check also

Solution 2:

I can't rate or comment, but in a fresh install of Ubuntu I used below then reinstalled and worked fine!

apt-get purge mysql-*
rm -fr /var/lib/mysql*

Solution 3:

I was getting this message when trying to start or restart mysql

Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.

and when using

systemctl status mysql.service

I get this message

mysql.service - MySQL Community Server <br>
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)<br>
   Active: activating (start-post) (Result: exit-code) since Thu 2016-11-10 17:09:58 AST; 24s ago<br>
Process: 31363 ExecStart=/usr/sbin/mysqld **(code=exited, status=1/FAILURE)**
Process: 31360 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre **(code=exited, status=0/SUCCESS)**<br>
Main PID: 31363 **(code=exited, status=1/FAILURE)**;         : 31364 (mysql-systemd-s)<br>
CGroup: /system.slice/mysql.service<br>
       └─control<br>
         ├─31364 /bin/bash /usr/share/mysql/mysql-systemd-start post
         └─31441 sleep 1<br>

The problem was because of issues in the file /etc/mysql/my.cnf. You can troubleshoot using mysql - it will show you where the error is like this :

mysql: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at **line 20**!
mysql: [ERROR] Fatal error in defaults handling. Program aborted!

The you can try to solve it by commenting out (be inserting # at the start of the line) the offending settings and so on.