我使用phpmysqli_connect登錄到MySQL數據庫(全部在本地主機上)<?php//DEFINE ('DB_USER', 'user2');//DEFINE ('DB_PASSWORD', 'pass2');DEFINE ('DB_USER', 'user1');DEFINE ('DB_PASSWORD', 'pass1');
DEFINE ('DB_HOST', '127.0.0.1');DEFINE ('DB_NAME', 'dbname');$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);if(!$dbc){
die('error connecting to database'); }?>MySQLServerini文件:[mysqld]# The default authentication plugin to be used when connecting to the serverdefault_authentication_plugin=caching_sha2_password
#default_authentication_plugin=mysql_native_password帶著caching_sha2_password在MySQLServerini文件中,根本不可能使用user 1或user 2登錄;錯誤:mysqli_CONNECT():服務器請求客戶端[緩存_sha2_密碼]中未知的身份驗證方法。帶著mysql_native_password在MySQLServerini文件中,可以使用user 1登錄,但使用user 2登錄時也會出現相同的錯誤;如何使用caching_sha2_password在MySQL服務器上?
3 回答

白衣染霜花
TA貢獻1796條經驗 獲得超10個贊
ALTER USER 'root' @ 'localhost' identified with mysql_native_password BY 'root123';
添加回答
舉報
0/150
提交
取消