16

I have been following the instructions on this page to install mysql on on Ubuntu 16.04.

I am half way down that page at the section titled "MySQL Install and Configure" and I run the command sudo apt-get install mysql-server. I have hit an error however, here is the output of that error in my terminal:

Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 41515 files and directories currently installed.)
Preparing to unpack .../mysql-common_5.7.12-0ubuntu1_all.deb ...
Unpacking mysql-common (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-client-5.7.
Preparing to unpack .../mysql-client-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-client-5.7 (5.7.12-0ubuntu1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up mysql-common (5.7.12-0ubuntu1) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mysql-server-5.7.
(Reading database ... 41563 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.12-0ubuntu1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.12-0ubuntu1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.12-0ubuntu1_all.deb ...
Unpacking mysql-server (5.7.12-0ubuntu1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up mysql-client-5.7 (5.7.12-0ubuntu1) ...
Setting up mysql-server-5.7 (5.7.12-0ubuntu1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
mysql_upgrade: Got error: 1045: Access denied for user 'debian-sys-maint'@'localhost' (using password: YES) while connecting to the MySQL server
Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...
Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

This is my first time setting up a server and also installing mysql. Not sure if this may be a possible cause of the error, but I had previously tried to install mysql but not following the LAMP process (I am newb figuring this out) and that was unsuccessful and I had to uninstall.

Darren Haynes
  • 371
  • 1
  • 3
  • 18
  • Welcome to AskUbuntu. In your log there is a line Access denied for user 'debian-sys-maint'@'localhost'. Where does that user come from? I wouldn't expect to find it on an Ubuntu system. – guntbert May 01 '16 at 20:39
  • Hi guntbert - with a little searching it seems its debian.cnf file. I found this http://stackoverflow.com/questions/11644300/access-denied-for-user-debian-sys-maint -- and looking at the answer that got 47 points (not the accepted answer) there is a password mismatch. I am giving it a shot - unsuccesfully, as I don't know what password is what! – Darren Haynes May 01 '16 at 21:07
  • This answer solve the problem to me without purge mysql: https://askubuntu.com/a/793545/597698 – Elkana Bardugo Sep 21 '16 at 21:12

6 Answers6

17

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:

  1. apt purge mysql-server and apt autoremove to clean all traces of the old MYSQL. The database data will not be destroyed.
  2. Remove everything from /etc/mysql directory.
  3. Verify there is no old Mysql packages left installed: dpkg -l | grep mysql
  4. apt install mysql-server to install

If these steps end in the same incomplete install, try the next step:

  1. Tail -n 20 /var/log/mysql/error.log
  2. 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
Kaceo
  • 171
6

Another good solution:

sudo apt-get purge mysql* && sudo apt-get install mysql-server
Eric Carvalho
  • 54,385
5

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.

Darren Haynes
  • 371
  • 1
  • 3
  • 18
3

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
1

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 
Spl2nky
  • 113
  • 5
1

First you have remove all packages of mysql-server:

sudo rm -rf /var/lib/mysql

Then install:

sudo apt-get install lamp-server^

Or you can do:

sudo apt-get install mysql-server
Zanna
  • 70,465