Error Installing mySql on Ubuntu 16.04
Solution 1:
This answer is also in answer to 16.04 upgrade broke mysql-server but which I cannot answer as the admin locked it to 10 reputation.
The error in APT occurs during the upgrade of Ubuntu to 16.04 (xenial) and Mysql from 5.5 to 5.7. Due to some packaging issues the APT upgrade ends in limbo because the post installation script of Mysql-server-5.7 fails to complete.
To solve the problem, try these steps:
-
apt purge mysql-server
andapt autoremove
to clean all traces of the old MYSQL. The database data will not be destroyed. - Remove everything from
/etc/mysql
directory. - Verify there is no old Mysql packages left installed:
dpkg -l | grep mysql
-
apt install mysql-server
to install
If these steps end in the same incomplete install, try the next step:
-
Tail -n 20 /var/log/mysql/error.log
- The errors could be a. bad password for debian-sys-maint b. no memory for Innodb
Solve 2a: You need to upgrade the Mysql system tables from 5.5 to 5.7
Edit my.cnf to include under '[mysqld]' the line "skip-grant-tables", service mysql start
, and mysql_upgrade --force -u root -p
Solve 2b: You are short of memory for Mysql Innodb pool (are you on a micro-size server?)
Edit my.cnf to include under '[mysqld]' the line innodb_buffer_pool_size = 20M
the default innodb pool is 128M, that is tight in a 512M VM
To clear the APT error, do the post install again
dpkg --configure -a
Solution 2:
Another good solution:
sudo apt-get purge mysql* && sudo apt-get install mysql-server
Solution 3:
Completely removing mysql and reinstalling was the solution I eventually came to. Although I had tried to uninstall and reinstall once unsuccessfully (thus bringing me to ask this question). I tried a more thorough uninstall after finding the advice on this page: Uninstall MySQL completely
Following the uninstall directions there and reinstalling solved the problem.
Solution 4:
This worked for me :
sudo apt-get remove --purge mysql*
This command will ask You if You want to REMOVE your databases from /var/lib/mysql
and also will remove all other instances of mysql !
So make a BACKUP of Your databases first !
After this I could install database by issuing the command :
sudo apt-get install mysql-server
Solution 5:
Try to remove all packages and files, then re-install the "mysql-server"
sudo apt-get remove --purge mysql-\*
sudo rm -rf /var/lib/mysql
sudo apt-get install mysql-server