Error: Could not connect to MySQL

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Error: Could not connect to MySQL

Postby uncertain » 14. June 2017 11:33

In early 2013 I was able to successfully create 8 different databases using XAMPP.

Recently, on one of my Windows 10 computers I downloaded the latest version 7 of XAMPP for PHP7 and MySQL 8 and I am no longer able to run databases because of the following error message:

Could not connect to MySQL: Access denied for user 'horatio'@'localhost' (using password: YES)

I assume that the code I used in 2013 is now out of date. I would be most grateful if you would let me know what the code should now be.

In 2013 the successful mysqli_connect.php code was as follows:

<?php
// This provides the information for accessing the database.
DEFINE ('DB_USER', 'horatio');
DEFINE ('DB_PASSWORD', 'hmsvictory');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'simpleIdb');
// Make the connection:
$dbcon = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
OR die ('Could not connect to MySQL: ' . mysqli_connect_error() );
// Set the encoding...
mysqli_set_charset($dbcon, 'utf8');
?>

The page that interacts with mysqli_connect.php contains the following linking code:

if (empty($errors)) { // If everything's OK.
// Register the user in the database...
require ('./mysqli_connect.php'); // Connect to the db.

Note: I am able to create databases and tables using the latest phpMyadmin that is included in XAMPP 7.
uncertain
 
Posts: 6
Joined: 26. December 2012 20:26
XAMPP version: 7.1.1
Operating System: Windows 10

Re: Error: Could not connect to MySQL

Postby Altrea » 14. June 2017 12:23

Hi,

The host / username / password combination you used in your script does not match the users your Database Management system knows.
So either you have not created that user, or that user has a different password or that user is not allowed to login from that host.

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11933
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 186 guests