Here is my code:
$dbServername = "localhost:3306"; //I also tried localhost, localhost:8080, 127.0.0.1
$dbUsername = "root1"; //new user created in myphpadmin
$dbPassword = "mypassword"; //I used a new password for the above user
$dbName = "loginsystem"; //the database exists in myphpadmin
$conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
if (!$conn) {
die('error connecting to database');
}
echo 'you have connected successfully';
For the dbServername, I've tried using localhost, localhost:8080, localhost:3306 and 127.0.0.1, but only 127.0.0.1 and localhost:3306 seem to go through and gives me the error at stake. I get different errors with localhost (No such file or directory*) and localhost:8080 (MySQL has gone away).
So given the IP as dbServername seems to passthrough and go to username and password check, I assume this is right. But then I get the error Access denied for user 'root'@'localhost'.
The username root without password exists is valid myphp. The database loginsystem also exists. I tried create new usernames and passwords and connect with this and it didn't work.
Edit01: I am using iOS. The users in mysql.user are 'root' without password, and I created one called 'root1' with a password to test. These 2 do not work when I tried them in my variables. I tried create new users names and restart MySQL after creation. I also re-created my database. I have XAMPP running here: /Users/jpb/.bitnami/stackman/machines/xampp/volumes/root/htdocs/wsd/includes/dbh.inc.php.
Edit02: Added a screenshot of my user accounts overview: click here to view
*Warning: mysqli_connect(): (HY000/2002): No such file or directory in /Users/jpb/.bitnami/stackman/machines/xampp/volumes/root/htdocs/wsd/includes/dbh.inc.php on line 8
I am running out of ideas. Hope you can help. Thank you
Edit03: I removed and un-installed XAMPP and MySQL. I installed AMPPS and now everything is fine: 'Success: A proper connection to MySQL was made. Host information: localhost:3306 via TCP/IP'. Thank you to those who helped and let me know if you run through similar issues, maybe I can help.