sudo mysql_secure_installation

As I was following the tutorial on installing a LAMP server I got to this command:

sudo mysql_secure_installation

and when prompted for a New password it returns this error message:

New password:

Re-enter new password: … Failed! Error: SET PASSWORD has no significance for user ‘root’@‘localhost’ as the authentication method used doesn’t store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters.

Any ideas out there?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Site Moderator
Site Moderator badge
June 7, 2023

Hey @jrmurchin,

That’s easily resolvable, don’t worry.

  1. Start the mysql client:
  1. sudo mysql
  1. Run the following SQL query:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'SetRootPasswordHere';

Replace SetRootPasswordHere with your actual password. 5. Then run the following command to secure it:

sudo mysql_secure_installation
  1. When promoted for the password enter the whatever you set when you ran the above SQL query
  2. That is all.
Bobby Iliev
Site Moderator
Site Moderator badge
June 7, 2023

Hi there,

You should be able to resolve this by following these steps:

  1. Start a new MySQL session:

    sudo mysql
  2. Run the following SQL query:

    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your-password-here';

    Note: change the your-password-here with an actual secure password

  3. Then run the mysql_secure_installation command again:

    sudo mysql_secure_installation
  4. When needed enter the your-password-here

Let me know how it goes!



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel