MySQL connection error (HY000/1045): Access denied for user

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

MySQL connection error (HY000/1045): Access denied for user

Postby ccaptn » 23. August 2018 21:20

Attention XAMPP & MySQL Gurus!
Help! Getting No traction on a DB connection error!
still cannot get the planets to line up!
*^&%$#!! totally frustrated!

I know that I am not the first to post on this subject, but am having no luck with anything I have googled so far.

Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost'
(using password: YES) in C:\xampp\htdocs\dbconnect.php on line 8 (the mysqli_connect call)

Environment:
Win 7 Pro
Installed XAMPP V3.2.2, running Apache & MySQL

Get this error trying to connect from php script to MySQL DB:

From the browser (Chrome), running this:
http://localhost:81/dbconnect.php

<?php
# db connect parms
$dbhost = 'localhost';
$dbuser = 'root';
$dbpwd = 's3kr1t';
$dbname = 'gmap1';

$dbcon = mysqli_connect($dbhost, $dbuser, $dbpwd, $dbname);
?>

Returns this error:

Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost'
(using password: YES) in C:\xampp\htdocs\dbconnect.php on line 8 (the mysqli_connect call)

So far I have done this:

* added a root password for root (default was no password)
* logged on to phpMyAdmin as root
* created a db (gmap1), table, and loaded data to it
* in phpMyAdmin selected the table data and successfully exported it
* confirmed that MySQL user root has all db access privileges:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD 'passroot';
So, root should be able to connect to the db!

I have worn google out researching this problem tried everything suggested to no avail

Any help much appreciated! I will even give you the rest of the day off!
ccaptn
 
Posts: 2
Joined: 23. August 2018 21:12
XAMPP version: 3.2.2
Operating System: Windows 7

Re: MySQL connection error (HY000/1045): Access denied for u

Postby ccaptn » 10. September 2018 21:33

*** update to my post ***

Still getting this access denied error trying to connect to mysql from the command line:

C:\xampp\mysql\bin>mysql --user=root --password
Enter password: ********
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

The Control Panel shows port 3308 being used for MySQL.
However, starting MySQL, gives the following "Problem detected" message.
But then it shows mysql running, despite the supposed port conflict.

Note that I set the port in C:\xampp\mysql\bin\my.ini to 3308:
port = 3308
I also set the port to 3308 in C:\Program Files\MariaDB 10.2\data\my.ini

However, I still get the following "Port 3306 in use" message, even though I changed the port to 3308 to fix the supposed port conflict.

2:52:36 PM [mysql] Attempting to stop MySQL app...
2:52:37 PM [mysql] Status change detected: stopped
2:52:40 PM [mysql] Problem detected!
2:52:40 PM [mysql] Port 3306 in use by ""C:\Program Files\MariaDB 10.2\bin\mysqld.exe" "--defaults-file=C:\Program Files\MariaDB 10.2\data\my.ini" "MariaDB""!
2:52:40 PM [mysql] MySQL WILL NOT start without the configured ports free!
2:52:40 PM [mysql] You need to uninstall/disable/reconfigure the blocking application
2:52:40 PM [mysql] or reconfigure MySQL and the Control Panel to listen on a different port
2:52:40 PM [mysql] Attempting to start MySQL app...
2:52:41 PM [mysql] Status change detected: running

I have run out of ideas of things to change to resolve this. Still can't connect to MySQL.
ccaptn
 
Posts: 2
Joined: 23. August 2018 21:12
XAMPP version: 3.2.2
Operating System: Windows 7

Re: MySQL connection error (HY000/1045): Access denied for u

Postby daddystakoyaki » 05. October 2018 08:24

port 3306 in use by MariaDB. You must change MariaDB port or change mysql port.

1. Stop the xampp server, if it is already running.
2. Edit the value to "port" in
xampp/mysql/bin/my.ini
Code:
# Password = your_password
port = 3306 ---> 3307
socket = "/ xampp / mysql / mysql.sock"

and here also

Code:
# The MySQL server [ mysqld ]
port = 3306 ---> 3307
socket = "/ xampp / mysql / mysql.sock"

maybe this can help you
daddystakoyaki
 
Posts: 2
Joined: 05. October 2018 07:58
Location: Jakarta
XAMPP version: v.3.2.2
Operating System: Windows 7 64 Bit

Re: MySQL connection error (HY000/1045): Access denied for u

Postby bretburrill » 06. October 2018 13:38

I too am having this problem. I am wondering if there could be a problem with having 2 sets of configuration files for mySql since there is the xampp configuration files and whatever files reside in c:/program files/mysql server 8.0/bin? Is this a possibility.

Please report here if you find a solution to your problem. I'm about to give up on trying to learn PHP because I can't find any development programs that I'm smart enough to install.
bretburrill
 
Posts: 5
Joined: 04. October 2018 23:30
XAMPP version: 3.2.2
Operating System: Windows 10

Re: MySQL connection error (HY000/1045): Access denied for u

Postby Nobbie » 06. October 2018 14:22

What is the need of having TWO MySQL installations? Do you also have TWO Word Installations, TWO InternetExplorers, TWO AdobePhotoshop, TWO Apache, TWO Notepads, TWO Ftp Servers etc.??

Simply de-install MySQL from Program Files.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: MySQL connection error (HY000/1045): Access denied for u

Postby bretburrill » 06. October 2018 14:46

Good point, Nobbie. I was operating under the false assumption that the xampp installer installed only a module for interfacing/configuring mySql. I didn't realize it actually installed a whole separate mySQL database installation.

"Do you also have TWO Word Installations, TWO InternetExplorers, TWO AdobePhotoshop, TWO Apache, TWO Notepads, TWO Ftp Servers etc.??"

Yes. I subscribe to the Noah's arc computing philosophy, maybe you've heard of it.
bretburrill
 
Posts: 5
Joined: 04. October 2018 23:30
XAMPP version: 3.2.2
Operating System: Windows 10

Re: MySQL connection error (HY000/1045): Access denied for u

Postby Nobbie » 06. October 2018 16:06

I haven't heard about it yet, but you probably mean a male and a female?!
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: MySQL connection error (HY000/1045): Access denied for u

Postby bretburrill » 07. October 2018 19:22

Well I don't know if its possible the OP did what I did and inadvertently installed 2 instances of mySQL, or if they ever solved the problem.

Once I figured out I had two separate installations I simply set the root password for the 2nd mySQL installation and exported my database from the first installation and imported it into the 2nd. Its working fine now.
bretburrill
 
Posts: 5
Joined: 04. October 2018 23:30
XAMPP version: 3.2.2
Operating System: Windows 10

Re: MySQL connection error (HY000/1045): Access denied for u

Postby nrabus » 04. May 2020 04:34

I use mysql for a networking class at Bradley University in Peoria, IL. My online text for the class uses xampp for the mysql chapter. I chnaged the port so was able to get to the mysqladmin browser site after I diabled QUIC. In a command prompt, when using the textbook entries to login, I get
C:\Users\Nick Rabus>mysql -h localhost -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

C:\Users\Nick Rabus>mysql -u root -p[Enter]
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

C:\Users\Nick Rabus>mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

C:\Users\Nick Rabus>mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

C:\Users\Nick Rabus>mysql -h localhost -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

C:\Users\Nick Rabus>UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root'; FLUSH PRIVILEGES;
'UPDATE' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Nick Rabus>mysql.exe
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)

=============================================================

I need to creat an account. I am about to reboot the browser during the steps shown in this video: https://www.youtube.com/watch?v=pByHKD7Y2jc

I haven't completed this step yet, but is there anything else I need to change such as the password hardcoded, or will that betaken care of by me when I can log in?

Thank you.

BTW I am new to actuall using mysql.
nrabus
 
Posts: 3
Joined: 09. February 2020 04:15
XAMPP version: 7.4.2
Operating System: Windows 10

Re: MySQL connection error (HY000/1045): Access denied for u

Postby pulse » 27. September 2020 14:09

Hi All,

has anyone been able to location a solution for this problem ?

I have the same problem and can't find away to get it working. I used root with no password, created a new user with access to 'data'. My sql connect string in PHP is returning access denied for both users. I have tried my new database and the myphpadmin db.

Would love some help...

Thanks.
pulse
 
Posts: 1
Joined: 27. September 2020 14:04
XAMPP version: 7.4.10
Operating System: windows


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 88 guests