mysql 8.0.16 Linux new users can not log

The reason given: ERROR 1045 (28000): Access denied for user 'ippbx_admin' @ 'localhost' (using password: YES).
8.0.16 version with some of the previous version adds some user changes his party to get instructions. Demo follows:
ysql> Create User 'ADMIN' @ '%' IDENTIFIED with caching_sha2_password by 'xhai-123'
->;
Query the OK, 0 rows affected (0.26 sec)

mysql> select user,host,authentication_string,plugin from mysql.user;
+------------------+-----------+------------------------------------------------------------------------+-----------------------+
| user | host | authentication_string | plugin |
+------------------+-----------+------------------------------------------------------------------------+-----------------------+
| admin | % | $A$005$q0{3bD]bt#>R9SeXb6Z4OS5mdwruFXD7TdiNzovrbbuI5xVxQGOSyKnL5 | caching_sha2_password |
| aplan | % |
B2E0C40A5667BF1783A28667466E1399EB00FBDF | mysql_native_password |
| ippbx_admin | 127.0.0.1 | $A$005$g^8x#aXm)T7{n94IvOO8/gPE7qqaVivgEIZ.oh/nrSVG8JCNJfskJBu6j22r. | caching_sha2_password |
| mysql.infoschema | localhost | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| mysql.session | localhost | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| mysql.sys | localhost | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | caching_sha2_password |
| root | localhost | $A$005$wcJW
k,I\WN.&L+T%V4QQKnlXTx21I/fXRAaWPOco0PgVi6Md3KzdNjZKBB0 | caching_sha2_password |
+------------------+-----------+------------------------------------------------------------------------+-----------------------+
8 rows in set (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.20 sec)

mysql> exit
Bye
root@root:/b# mysql -u admin -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 42
Server version: 8.0.16 MySQL Community Server - GPL

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye

It can be found not to restrict login host of ways to succeed.

There is a ippbx_admin database user, we use the insert into ways to add (insert into the User (Host, user) values ( "127.0.0.1", "ippbx_admin");), try to log failed to succeed:
root @ root: / b # MySQL ippbx_admin -p -u
the Enter password:
ERROR 1045 (28000): Access denied for the User 'ippbx_admin' @ 'localhost' (a using password: YES)

It can be found using the default localhost resolution, while the database is 127.0.0.1, previously did not pay attention to this problem, a waste of time for a long time, and then change the database host field to localhost

mysql> update user set host="localhost" where user= "ippbx_admin";
Query OK, 1 row affected (0.17 sec)
Rows matched: 1 Changed: 1 Warnings: 0

mysql> exit
Bye
root@root:/b# mysql -u ippbx_admin -p
Enter password:
ERROR 1045 (28000): Access denied for user 'ippbx_admin'@'localhost' (using password: YES)

I found still could not log in, and then we use the alter to change the password, note 'ippbx_admin' @ 'localhost' need to be consistent with the database
MySQL> alter the User 'ippbx_admin' @ 'localhost' IDENTIFIED with caching_sha2_password by 'xhai-123';
Query the OK , 0 rows affected (0.13 sec)

Miraculous discovery can log, Nice
root @ root: ~ # MySQL -u -p ippbx_admin
the Enter password:
.. Is available for purchase at The MySQL Monitor Commands to End with; or \ G
Your MySQL Connection the above mentioned id IS 60
Server Version: 8.0.16 MySQL Community Server - GPL

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Related instructions use:
. 1, SELECT User, Host, authentication_string, plugin from the mysql.user; # access user information, user password field of the table is not in use, to use authentication_string, refer to the following values;

The caching_sha2_password and sha256_password authentication plugins provide more secure password encryption than the mysql_native_password plugin, and caching_sha2_password provides better performance than sha256_password. Due to these superior security and performance characteristics of caching_sha2_password, it is as of MySQL 8.0 the preferred authentication plugin, and is also the default authentication plugin rather than mysql_native_password.

2, GRANT ALL PRIVILEGES ON . The TO 'ippbx_admin' @ 'localhost' the WITH GRANT OPTION; # account all permissions granted to test.

PS: the same password for different values ​​stored in the database, account should be more secure.

Guess you like

Origin www.cnblogs.com/xhai/p/11220945.html