无法使用 XAMPP 连接到 MySQL
这个脚本:
<?php
if(!$con = mysqli_connect("localhost", "root", ""))
die("failed to connect");
?>
导致此错误:
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost'
(using password: NO) in C:\xampp\htdocs\dashboard\login\connection.php on line 2
failed to connect
root账户确实没有密码;我可以通过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
(见phpMyAdmin access denied for user 'root'@'localhost' (using password: NO))。
没有效果。
这可能是相关的:当我通过 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