简体   繁体   中英

PHP - Mysql: can't connect to database

I've setup mysql server 8.0, Apache2.4, php 7.2 and created a simple database.

As a start I am trying to write a php code for connecting to the database but i can't figure it out. My code:

<?php
$con = mysqli_connect("localhost","Don","password","db1");

if (!$con) {
echo "Error: " . mysqli_connect_error();
exit();
}

echo 'Connected to MySQL';
?>

I get Error: The server requested authentication method unknown to the client.

I've tried several things: connect to root, 192.168.0.1 instead of localhost but nothing is working.

Any ideas? Thanks.

(post for someone who has the same problem)

i searched about the old password issue but i couldnt find the old_passwords var, not even in my.cnf file.

so what i did was uninstalling mysql server 8.0 and installing 5.7.2 and it worked.

ps i didnt configure anything differently while setting up the 5.7.2 version.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM