본문으로 바로가기

[php][mysql]DB 연결 함수

category PHP 2020. 7. 6. 11:02
728x90
반응형

php8에서 비밀번호 관련하여 caching_sha2_password로 바뀌어, 비밀번호등 DB정보가 정확해도 아래의 warning이 뜬다.

mysqli_connect

Warning: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in /Users/LimSeolHee/Documents/apmTest/index.php on line 11

Warning: mysqli_connect(): (HY000/2054): The server requested authentication method unknown to the client in /Users/LimSeolHee/Documents/apmTest/index.php on line 11
$link = mysqli_connect($host, $username, $password, $database, $port);

if (!$link) {
    echo "Error: Unable to connect to MySQL." . "<br />";
    echo "Debugging errno: " . mysqli_connect_errno() . "<br />";
    echo "Debugging error: " . mysqli_connect_error() . "<br />";
}

 

728x90
반응형