mysql installation stuck on Ubuntu 16.04 (no root user privilege)

An easy solution is to sudo killall mysqld while the apt-get operation is running.

The apt operation just kept on running without any errors after that(!)

Source: https://bugs.launchpad.net/ubuntu/+source/mysql-5.7/+bug/1596815


At last I got the workaround. Here is what I did

  • Uninstall mysql using sudo apt purge mysql*
  • Remove /etc/mysql folder
  • Remove /var/lib/mysql, /var/lib/mysql-files, /var/lib/mysql-kering folders.
  • Reboot
  • Install mysql using sudo apt-get install mysql-server

This time mysql installed successfully without getting stuck. While installation it prompted me for root password and I provided one. After the installation I logged in with root with my provided password. This time creating new user, updating all works fine. Now, here is the result of show grants:

+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION        |
+---------------------------------------------------------------------+

Although I still don't know why at first time it didn't work. I tried by removing only the cnf file but that didn't work. When I removed all mysql folders inside /var/lib then it worked. So I guess there was some file inside /var/lib/msyql directory which prevented to create any new user (even root user).


I've been looking for months for a solution to the problems with mysql_server configuration, which froze when installing anything else, thus having to kill the processes and manually start mysql. This also made me have to start MySQL manually each time I restarted the computer.

I edited the /var/lib/dpkg/info/mysql-server-5.7.postinst and I noticed the configure) part doesn't return anything so it just freezes.

You just need to edit that file and add at the end of the configure) section (before the section on abort-upgrade|abort-remove|abort-configure) a line that says "exit 0", around line 290. Mine looks now like this:

    # To avoid downgrades. This has to happen after the database is created, or --initialize will fail
touch $mysql_statedir/debian-5.7.flag

    exit 0   # Corregimos el bug del postinst de mysql

;;
abort-upgrade|abort-remove|abort-configure)