PHP Uncaught mysqli_sql_exception: Access denied for user
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
<password>
In mysqld I changed the listening addresses:
# bind-address = 127.0.0.1
bind-address = 127.0.0.1,192.168.x.y
# mysqlx-bind-address is for the X plugin
mysqlx-bind-address = 127.0.0.1,192.168.x.y
I connect to the DB using php like this
$host = 'localhost'; // "127.0.0.1"
// $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);
$conn->set_charset('utf8mb4');
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 !!
Subject
Written By
Posted
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.