我正在使用Abyss X1启动Web服务器,只是尝试使用以下两个脚本通过PHP实现MySQL服务器:
connect_db.php:
#Connect on 'localhost' for user 'admin'
#with password 'RoboticCowboy2019' to database 'site_db'.
$dbc = mysqli_connect
( 'localhost' , 'admin', 'password', 'site_db' )
OR die
( mysqli_connect_error() );
#Set encoding to match PHP script encoding.
mysqli_set_charset($dbc, 'utf8' );
和
require.php:
#Incorporate the MySQL connection script.
require ('../connect_db.php');
#Display MySQL version and host.
if(mysqli_ping($dbc)){
echo 'MySQL Server'.mysqli_get_server_info($dbc).'on'.mysqli_get_host_info($dbc);
}
但是,当我转到http://localhost/require.php时,出现以下错误:
“警告:mysqli_connect():服务器在第6行的/ Applications / Abyss Web Server / connect_db.php中请求客户端[caching_sha2_password]未知的身份验证方法”
“警告:mysqli_connect():(HY000 / 2054):服务器在第6行的/ Applications / Abyss Web Server / connect_db.php中请求客户端未知的身份验证方法 服务器请求客户端未知的身份验证方法”
我正在遵循一本我知道已经过时的书的说明,但是到目前为止,我已经能够解决所有问题。我还读到它与MySQL更新和实现sha2有关,而PHP仍然没有?我正在为compsci课做这件事,因此,我将非常感谢我所能提供的所有帮助。
谢谢!
答案 0 :(得分:0)
更改用户
ALTER USER 'mysqluser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'mysqlpassword';
或使用
shell>mysql --default-auth=mysql_native_password