MySQL Forums
Forum List  »  PHP

PHP Uncaught mysqli_sql_exception: Access denied for user
Posted by: Louis at oracle
Date: March 28, 2023 11:55AM

I try to run an apache webserver on an Ubuntu 22.04 LTS server.

I installed mysql (8.0.32), php (8.1.2) and apache2. I manage the mysql instance remotely via mysql workbench on a windows machine

The MySQL has a DB which I can configure locally and via the workbench;
I defined an user for the DB which has mysql access via the ubuntu commandline via mysql -u user -p

In mysqld I changed the listening addresses:
# bind-address =
bind-address =,192.168.x.y
# mysqlx-bind-address is for the X plugin
mysqlx-bind-address =,192.168.x.y

I connect to the DB using php like this
$host = 'localhost'; // ""
// $username = "mr_x"; // new pas type
$username = 'mr_y'; // old pw type
$password = '<thepassword>';
$dbname = 'some_db';

try {
// Establish connection to database use mysqli
//$mysqli = new mysqli("localhost", "username", "password", "databaseName");
$conn = new mysqli($host,$username,$password,$dbname);

This SHOULD imho work ... however it does not ...

PHP Fatal error: Uncaught mysqli_sql_exception: Access denied for user 'mr_y'@'localhost' (using password: YES) in /var/www/etc.

I have tried all kind of options to fix this issue even temporarily installing php8.2 (ubuntu is running in an VM), which did not solve the problem. So I did revert to the formal 8.1 version

Given all the effort I put in trying to solve the problem ...
I Sincerely hope any one has a clue / knows how to fix this !!

Options: ReplyQuote

Written By
PHP Uncaught mysqli_sql_exception: Access denied for user
March 28, 2023 11:55AM

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.