`mysql_secure_installation` fails with permissions issue

Hello! I used the 1-click install image to set up my blog on Digital Ocean. I am trying to go through the recommended server hardening and security steps but getting a permissions issue when I run mysql_secure_installation or sudo mysql_secure_installation. Here is full output:

$ sudo mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:
Error: Access denied for user 'root'@'localhost' (using password: YES)

This happens when I run as root user, ghost-mgr, or a separate user I created- always access denied for user root@localhost even when I enter the correct password for the user or root. Any advice? Thanks in advance.

ah ok, figured it out from digitalocean-1-click/boot_strap.sh at 884d3be227578df4b273db42ca5da8b78638dabf · TryGhost/digitalocean-1-click · GitHub

when logged into DO as root (maybe works as other users, not sure), I can do

$ cat ~/.digitalocean_password
# see the password, then do:
$ sudo mysql_secure_installation

This is what I’d do before running mysql_secure_installation.


ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'password';

I think I couldn’t even run mysql since I didn’t have the password for the mysql user- it was called root but had different credentials than my Digital Ocean root user. All resolved now though!