Page 1 of 1

Error: Could not connect to MySQL

PostPosted: 14. June 2017 11:33
by uncertain
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.

Re: Error: Could not connect to MySQL

PostPosted: 14. June 2017 12:23
by Altrea
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