Comment 3 for bug 1980466

Revision history for this message
Michał Małoszewski (michal-maloszewski99) wrote :

Hi,

I think here is the workaround for it.
The reason for that issue is that this script will attempt to set a password for the installation's root MySQL account, but by default on Ubuntu installations, this account is not configured to connect using a password.
To avoid that problem, you will need to adjust how your root MySQL user authenticates.
Try:
# sudo mysql
then:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'newpassword';
mysql> exit

Now you will be able to run 'mysql_secure_installation' without any further issues.
But remember to reopen MySQL and change the root user's authentication method back to the default, auth_socket.
Run:
$ mysql -u root -p
Then:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;

You can once again connect to MySQL as root using sudo mysql.