日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql8.0新用户无法连接_mysql 8.0.16 Linux新建用户无法登录

發(fā)布時間:2023/12/19 数据库 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql8.0新用户无法连接_mysql 8.0.16 Linux新建用户无法登录 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

報錯原因:ERROR 1045 (28000): Access denied for user 'ippbx_admin'@'localhost' (using password: YES)。

8.0.16版本與先前的一些版本添加用戶有些改變,一行指令就搞定。演示如下:

ysql> create user 'admin'@'%' identified with caching_sha2_password by 'xhai-123'

-> ;

Query 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

可以發(fā)現(xiàn)以不限制登錄主機(jī)的方式可以成功。

數(shù)據(jù)庫中有一個ippbx_admin用戶,我們使用insert into 方式添加(insert into user(host,user) values("127.0.0.1","ippbx_admin");),嘗試登錄卻沒能成功:

root@root:/b# mysql -u ippbx_admin -p

Enter password:

ERROR 1045 (28000): Access denied for user 'ippbx_admin'@'localhost' (using password: YES)

可以發(fā)現(xiàn)使用localhost的默認(rèn)解析,而數(shù)據(jù)庫中的是127.0.0.1,先前也沒注意這個問題,浪費(fèi)了好久時間,于是改變數(shù)據(jù)庫中host字段為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)

發(fā)現(xiàn)還是沒能登錄,之后我們使用alter 去修改密碼,注意'ippbx_admin'@'localhost' 需要與數(shù)據(jù)庫保持一致

mysql> alter user 'ippbx_admin'@'localhost' identified with caching_sha2_password by 'xhai-123';

Query OK, 0 rows affected (0.13 sec)

神奇的發(fā)現(xiàn)可以登錄了,nice

root@root:~# mysql -u ippbx_admin -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection 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>

相關(guān)指令使用:

1、select user,host,authentication_string,plugin from mysql.user;#查看用戶信息,user表中不在使用password字段,改為使用authentication_string,取值參考如下;

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 . TO 'ippbx_admin'@'localhost' WITH GRANT OPTION;#授予test賬戶所有權(quán)限.

PS:相同的密碼在數(shù)據(jù)庫中存儲了不同的值,賬戶應(yīng)該更加安全。

總結(jié)

以上是生活随笔為你收集整理的mysql8.0新用户无法连接_mysql 8.0.16 Linux新建用户无法登录的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。