Last updated: Apr 4, 2024
Reading timeยท3 min
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'@'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
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'":
mysql_secure_installation
command.sudo pkill -f mysql_secure_installation # ๐๏ธ or the following command sudo killall -9 mysql_secure_installation
sudo mysql
native_password
. Note that the
command ends with your_root_password_here
. Don't just copy and paste it
into your terminal.your_root_password_here
placeholder with the actual password for your MySQL root user.# ๐๏ธ 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
Type exit
after issuing the ALTER USER
command.
Rerun the sudo mysql_secure_installation
command and enter the password you
specified in the ALTER USER
command.
sudo mysql_secure_installation
We changed the default authentication method to mysql_native_password
, so you
can connect to the MySQL server with the following command.
mysql -u root -p
Note that you will be prompted for the password you set when issuing the
mysql_secure_installation
command.
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.
ALTER USER 'root'@'localhost' IDENTIFIED WITH auth_socket;
Use the following command to verify that the authentication method is set to the
auth_socket
plugin.
SELECT user, plugin FROM mysql.user WHERE user IN ('root')\G
Use the exit
command to disconnect and issue the sudo mysql
command to
connect.
exit # ๐๏ธ When using auth_socket plugin for authentication sudo mysql # ๐๏ธ When using mysql_native_password plugin mysql -u root -p
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.
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.