无法使用phpMyAdmin

问题描述

我最近安装了WAMP的最新版本,但是访问MysqL(MariaDB)服务器时遇到问题。我可以使用MariaDB控制台访问服务器。因此,我确定密码用户名正确,并且服务器正在运行。

WAMP: 3.2.2
Apache: 2.4.41
PHP: 7.4.0
MariaDB: 10.4.10
PHPMyAdmin: 5.0.2

当我使用PHPMyAdmin网页访问时:

enter image description here

我还尝试使用一个简单的测试脚本进行访问:

<?PHP
$servername = "localhost";
$username = "root";
$password = "";

try {
  $conn = new PDO("MysqL:host=$servername;dbname=myDB",$username,$password);
  // set the PDO error mode to exception
  $conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
  echo "Connected successfully";
} catch(PDOException $e) {
  echo "Connection Failed: " . $e->getMessage();
}
?>

在浏览器中运行时,我遇到类似的错误

enter image description here

从命令行运行相同的脚本即可:

enter image description here

我尝试更改$servername = "127.0.0.1";并得到相同的结果。

我还尝试使用以下命令从MariaDB控制台更改root用户密码

  FLUSH PRIVILEGES;
  ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

密码已更改,我已经更新了测试脚本$password = "MyNewPass";,结果仍然相同。

WAMP,右键单击,工具->测试端口3306。还会给出预期的结果:

***** Test which uses port 3306 *****

===== Tested by command netstat filtered on port 3306 =====


Test for TCP
Your port 3306 is used by a processus with PID = 8660
The processus of PID 8660 is 'MysqLd.exe' Session: Services
The service of PID 8660 for 'MysqLd.exe' is 'wampmariadb64'
This service is from Wampserver - It is correct

Test for TCPv6
Your port 3306 is used by a processus with PID = 8660
The processus of PID 8660 is 'MysqLd.exe' Session: Services
The service of PID 8660 for 'MysqLd.exe' is 'wampmariadb64'
This service is from Wampserver - It is correct

任何帮助将不胜感激。

解决方法

似乎您应该从wamp工具配置phpMyAdmin,并且应该使用ipconfig控制台从本地IP地址输入,而不是php脚本可以工作。