Php Can';我不能在我的个人计算机上连接到我的数据库,但它可以在其他计算机上工作

Php Can';我不能在我的个人计算机上连接到我的数据库,但它可以在其他计算机上工作,php,mysql,xampp,Php,Mysql,Xampp,无法使用XAMPP连接到MySQL 此脚本: <?php if(!$con = mysqli_connect("localhost", "root", "")) die("failed to connect"); ?> 根帐户确实没有密码;我可以通过shell登录MySQL: # mysql -u root Welcome to the MariaDB monitor.

无法使用XAMPP连接到MySQL

此脚本:

 <?php
   if(!$con = mysqli_connect("localhost", "root", ""))
      die("failed to connect");    
 ?>
根帐户确实没有密码;我可以通过shell登录MySQL:

# mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 29
Server version: 10.4.17-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>
我尝试添加这一行--
$cfg['Servers'][$I]['auth_type']='HTTP'到config.inc.php
(见附件)。
没有效果

这可能是相关的:通过XAMPP启动MySQL时出现的错误:

9:53:17 AM  [mysql]     Problem detected!
9:53:17 AM  [mysql]     Port 3306 in use by "Unable to open process"!
9:53:17 AM  [mysql]     MySQL WILL NOT start without the configured ports free!
9:53:17 AM  [mysql]     You need to uninstall/disable/reconfigure the blocking application
9:53:17 AM  [mysql]     or reconfigure MySQL and the Control Panel to listen on a different port

看起来您已经为root用户设置了密码。@Jens,那么他们为什么能够通过MySQL CLI客户端登录?不,root用户没有密码。这可能与此相关:“-如果MySQL甚至没有启动,那么如果您也无法连接到它,这应该不会太令人惊讶。@Dharman可能他们已经运行了一个不同的实例,或者类似的。
9:53:17 AM  [mysql]     Problem detected!
9:53:17 AM  [mysql]     Port 3306 in use by "Unable to open process"!
9:53:17 AM  [mysql]     MySQL WILL NOT start without the configured ports free!
9:53:17 AM  [mysql]     You need to uninstall/disable/reconfigure the blocking application
9:53:17 AM  [mysql]     or reconfigure MySQL and the Control Panel to listen on a different port