0

Can't connect to MySQL using XAMPP

This script:

 <?php
   if(!$con = mysqli_connect("localhost", "root", ""))
      die("failed to connect");    
 ?>

causes this error:

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

The root account indeed doesn't have a password; I can log into MySQL through the shell:

# 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)]>

I have tried adding this line -- $cfg['Servers'][$i]['auth_type'] = 'HTTP'; to config.inc.php (see phpMyAdmin access denied for user 'root'@'localhost' (using password: NO)). No effect.

This might be relevant: errors I get when I start MySQL through XAMPP:

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

0 Answers0