I was trying to set password for root. When I run:
mysql> SELECT * from mysql.user where User="root";
It shows:
+-----------+------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-----------------------+------------------+-----------------------+-------------------+----------------+
| Host | User | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | Create_tablespace_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections | plugin | authentication_string | password_expired | password_last_changed | password_lifetime | account_locked |
+-----------+------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-----------------------+------------------+-----------------------+-------------------+----------------+
| localhost | root | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | | | | | 0 | 0 | 0 | 0 | mysql_native_password | | N | 2018-06-13 15:11:59 | NULL | N |
+-----------+------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+-----------------------+------------------+-----------------------+-------------------+----------------+
This Document says that,
The mysql_native_password native authentication plugin is backward compatible. Older clients that do not support authentication plugins do use the native authentication protocol, so they can connect to servers that support pluggable authentication.
But technically I'm not getting much. Does it have to do anything with root user password?
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<password>';
and
ALTER USER 'root'@'localhost' IDENTIFIED BY '<password>';
Does it make any difference?
UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND plugin = 'unix_socket';? Does it mean it wasn't set already? – d a i s y Jun 14 '18 at 03:42it is not very secure (it uses just a hash of the password)is not exactly correct: the authentication itself doesn't use plain hashes and thus the password or its hash is never transmitter over the wire. The server does store theSHA1(SHA1(password))hash in its unsalted form in themysql.usertable which is then used in the authentication. The actual authentication is as follows:SHA1(password) ^ SHA1(seed + SHA1(SHA1(password)))wherepasswordis the plaintext password andseedis a 20 byte random nonce. – markusjm Mar 23 '23 at 10:14