I am making simple mysqli connection to my database on Godaddy windows hosting, my code is as follows :
<?php
error_reporting(E_ALL & ~(E_STRICT|E_NOTICE));
$host = 'localhost';
$user = 'root_user_name';
$password = 'root_user_pass';
$db = 'my_database';
$cxn = mysqli_connect($host,$user,$password) or
die(mysqli_connect_error()); // <<<<<< line 9
mysqli_select_db($cxn, $db ) or die(mysqli_connect_error());
die('test');
I am sure of the granted username and password as well as the database name, all my credentials are proper, though I am getting this error:
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root_user_name'@'localhost' (using password: YES) in G:\path\to\file\index.php on line 9 Access denied for user 'root_user_name'@'localhost' (using password: YES)
I got this working on localhost with same database name and credentials using wamp server, I am not much into IIS server and windows hosting.. Any help will be appreciated.
I once had this problem and simply resolved it by setting the real IP address of the database server in my host when connecting to the database. To get the IP address, log into your hosting account and access the databases, then click on managing the database you want, this will take you to phpMyAdmin. To the right there is a block with title Database Server, you can find the server IP address in the first list item. Use it in your $host rather than localhost :
$host = '51.51.51.51'; // <<<< just a fake IP address for the example
I had a lot of harsh time to find out what was going wrong, I even contacted the support and got this reply :
Joshua - I think the permissions are the cause of the issue. Once you have them properly updated, the problem should go away.
They stated that the files permission could be the issue, I updated the file permissions but didn't resolve it.
Sometimes the solution is much closer than you can think of!!
The new MySQL database setup form will accept mixed case characters as the database name/username, it will silently convert them to lowercase on you. The phpMyAdmin login, then, is case sensitive, so you may want to copy and paste from the Control Center into phpMyAdmin to be sure you’re feeding it the correct username.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With