MySQL Installation Stuck on Ubuntu 16.04 – No Root Privilege Fix

16.04MySQLserver

In my ubuntu 16.04 server I am trying to install mysql by the following command

sudo apt-get install mysql-server

Each time it got stuck with the message :

update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode 
Renaming removed key_buffer and myisam-recover options (if present) 
Checking if update is needed.
This installation of MySQL is already upgraded to 5.7.16, use --force if you still need to run mysql_upgrade

I have to press Ctrl+z to stop it. I have checked the log file in /var/log/mysql/error.log and last 10 line of it shows this result:

2017-01-18T09:07:30.329930Z 0 [Note] InnoDB: Buffer pool(s) load completed at 170118  9:07:30
2017-01-18T09:07:30.335086Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2017-01-18T09:07:30.335137Z 0 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2017-01-18T09:07:30.335157Z 0 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
2017-01-18T09:07:30.335216Z 0 [Note] Server socket created on IP: '127.0.0.1'.
2017-01-18T09:07:30.349491Z 0 [Note] Event Scheduler: Loaded 1 event
2017-01-18T09:07:30.349749Z 0 [Note] Execution of init_file '/var/lib/mysql-files/tmp.sJ5rMac6mK' started.
2017-01-18T09:07:30.350543Z 1 [ERROR] 1396  Operation ALTER USER failed for 'root'@'localhost'
2017-01-18T09:07:30.350737Z 0 [Note] Execution of init_file '/var/lib/mysql-files/tmp.sJ5rMac6mK' ended.
2017-01-18T09:07:30.350864Z 0 [Note] mysqld: ready for connections.

After a reboot I logged in to mysql by mysql -u root. within mysql I cannot do any operation, creating new user or modifying privileges nothing. I am just able to browse through default databases

  • information_schema
  • test

when I typed show grants it shows me the following result

+--------------------------------------+
| Grants for @localhost                |
+--------------------------------------+
| GRANT USAGE ON *.* TO ''@'localhost' |
+--------------------------------------+

Which is quite strange. To make sure of this I checked the user_privileges table in information_schema which gives me this:

+----------------+---------------+----------------+--------------+
| GRANTEE        | TABLE_CATALOG | PRIVILEGE_TYPE | IS_GRANTABLE |
+----------------+---------------+----------------+--------------+
| ''@'localhost' | def           | USAGE          | NO           |
+----------------+---------------+----------------+--------------+

How can I enable root access to create, update?

Best Answer

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