Re: MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Posted by: Ricardo Mastrangelo
Date: January 06, 2019 05:04PM

Hi Filipe, I saw the help you provided to willians, great! On my side I have the exact same problem and been trying to solve it out for the past 48 hours. I ended up here. However, my code is in PHP. Could you help? I paste it here:

The message I when submitting the from from my website:

Connect Error(1045)Access denied for user 'root'@'localhost' (using password: NO)

The PHP code to connect to mysql database:

<?php
$firstname = $_POST['first_name'];
$familyname = $_POST['family_name'];
$birthdate = $_POST['birthdate'];
$gender = $_POST['gender'];
$email = $_POST['email'];
$phonenumber = $_POST['phone_number'];
$password = $_POST['pass'];
$passrepeat = $_POST['pass-repeat'];

if (!empty($firstname) || !empty($familyname) || !empty($birthdate) || !empty($gender) || !empty($email)
|| !empty($phonenumber) || !empty($password) || !empty($passrepeat))

{$hostname = "localhost";
$username = "ricardo";
$password = "";
$dbname = "ricardo";

$conn = new mysqli ($hostname, $username, $password, $dbname);
if (mysqli_connect_error()) {
die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
}
else {$SELECT = "SELECT e_mail FROM registration WHERE e_mail = ? Limit 1";
$INSERT = "INSERT INTO registration (first_name, family_name, birthdate, gender, email, phone_number, pass, pass-repeat)
values (?,?,?,?,?,?,?,?)";
$stmt = $conn ->perpare($SELECT);
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt->bind_result();
$stmt->store_result();
$rnum = $stmt->num_rows;

if ($rnum==0){
$stmt->close();
$stmt->bind_param("ssissss", $firstname, $familyname, $birthdate, $gender, $email, $phonenumber, $password, $passrepeat);
$stmt->execute();
echo "New record inserted successfully";
}
else {
echo "Someone already register using this email";
}
$stmt->close();
$conn->close();

}
} else { echo "All fields are required";
die();
}

?>

Options: ReplyQuote


Subject
Written By
Posted
Re: MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
January 06, 2019 05:04PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.