Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost'

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
3 min

banner

# Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost'

The error "Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost'" occurs when we run the mysql_secure_installation script on Ubuntu because the script tries to set a password for the root MySQL user.

However, the default authentication method is to use the auth_socket plugin and connect using a UNIX socket, not a password.

failed error set password has no significance for user root

shell
... 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. New password
The error message suggests using the ALTER USER command to change the authentication parameters and this is what we'll do.

To solve the error "Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost'":

  1. Open a new terminal window and terminate the process in which you issued the mysql_secure_installation command.
shell
sudo pkill -f mysql_secure_installation # ๐Ÿ‘‡๏ธ or the following command sudo killall -9 mysql_secure_installation

mysql secure installation terminated

  1. Connect to the MySQL server as an administrator.
shell
sudo mysql

mysql connect as administrator

  1. Switch the authentication method to native_password. Note that the command ends with your_root_password_here. Don't just copy and paste it into your terminal.
Replace the your_root_password_here placeholder with the actual password for your MySQL root user.

mysql native password authentication

shell
# ๐Ÿ‘‡๏ธ replace `your_root_password_here` with your actual password ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_root_password_here'; # ๐Ÿ‘‡๏ธ exit after issuing the command exit
  1. Type exit after issuing the ALTER USER command.

  2. Rerun the sudo mysql_secure_installation command and enter the password you specified in the ALTER USER command.

shell
sudo mysql_secure_installation

issue mysql secure installation command

  1. Go through the secure installation process.

go through mysql secure installation process

  1. Complete the secure installation process.

complete secure installation process

We changed the default authentication method to mysql_native_password, so you can connect to the MySQL server with the following command.

shell
mysql -u root -p

Note that you will be prompted for the password you set when issuing the mysql_secure_installation command.

mysql connect using password

If you want to change the MySQL root user to use the auth_socket plugin for authentication (UNIX socket instead of a password), issue the ALTER USER command.

shell
ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;

set authentication method to auth socket

Use the following command to verify that the authentication method is set to the auth_socket plugin.

shell
SELECT user, plugin FROM mysql.user WHERE user IN ('root')\G

verify auth method is auth socket

Use the exit command to disconnect and issue the sudo mysql command to connect.

shell
exit # ๐Ÿ‘‡๏ธ When using auth_socket plugin for authentication sudo mysql # ๐Ÿ‘‡๏ธ When using mysql_native_password plugin mysql -u root -p

connect to mysql server using auth socket

When you issue the sudo mysql command, you might get prompted for a password. However, the password is not associated with mysql, it is your Linux password for issuing a sudo command.

The mysql_native_password plugin enables you to connect using a password, whereas the auth_socket plugin (default) enables you to connect using a UNIX socket.

# Conclusion

The error "Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost'" occurs when we run the mysql_secure_installation script on Ubuntu because the script tries to set a password for the root MySQL user with auth_socket authentication enabled.

To solve the error, use the ALTER USER command to change the authentication parameters.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev