Look at your php code at first
$query = mysqli_query($con,"SELECT * FROM `user` WHERE `name`='$name' && `password`='$password'");
$rows = mysqli_num_rows($query);
After my fresh installation of MySQL 8.0.24 on Ubuntu 20.10, I was unable to login with
mysql -u root
which results in
Error 1698 (28000): Access denied for user 'root'@'localhost'
However, I was able to login with
sudo mysql -u root
I guess this is because super user in linux is the root user.