Ubuntu – Cannot install MySQL – libaio.so.1: cannot open shared object file: No such file or directory – Live Installation with Persistence

live-usbMySQLsoftware installation

I decided to sign up to askubuntu.com, because i really need an advice from experts: I made, with mkusb, a persistent USB Live installation of Ubuntu 16.10, since I'd like to have a portable development environment. Everything went good, and I'm writing from that Live right now.

Now the question: I managed to install apache2, but after hours and hours of searching in the web, and also on this site, I cannot still properly install MySQL server. After re-executing many time the installation, I continue to get this error:

 Setting up mysql-server-5.7 (5.7.17-0ubuntu0.16.10.1) ...
ERROR: Unable to start MySQL server:
mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
Please take a look at https://wiki.debian.org/Teams/MySQL/FAQ for tips on fixing common upgrade issues.
Once the problem is resolved, run apt-get --fix-broken install to retry.
dpkg: error processing package mysql-server-5.7 (--configure):
 subprocess installed post-installation script returned error exit status 127
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
No apport report written because the error message indicates its a followup error from a previous failure.
                          Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

And if I run

sudo mysqld --initialize

The terminal still reports

mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

So i thought to search for this "libaio.so.1" as well, and I finished up installing the libraries "libaio1" and "libaio-dev" (which seems to be the same). The result, however didn't change even if those libraries are correctly installed.

Is this caused from the fact that I'm in a LiveUSB?

I really hope you can help me. I apologize in advance for any possible mistake made in this question. Thank you.

Best Answer

After more many hours of research, i found that the problem wasn't the LiveUSB or the library itself. The problem was AppArmor, which blocked MySQL to use that library. So I disabled it:

sudo /etc/init.d/apparmor stop
sudo /etc/init.d/apparmor teardown
sudo update-rc.d -f apparmor remove

And a not-so-orthodox way, I completely removed AppArmor, to prevent future problems with:

sudo apt-get purge apparmor

Then I uninstalled and reinstalled MySQL Server flawlessy. It works!