Click here to Skip to main content
14,241,004 members
Rate this:
Please Sign up or sign in to vote.
See more:
I get this when I execute a PHP script to query the DB. Godaddy person was no help at all. I access this same DB with .NET apps and with MySql Workbench.


Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user 'mystrainfamily'@'184.168.27.82' (using password: YES) in D:\Hosting\2451228\html\bobbystrain\Strains\php\scripts\connect.php on line 15

What I have tried:

I talked to Godaddy rep. No help. This is typical response.
Posted
Comments
Mohibur Rashid 4-Jun-19 18:20pm
   
Do you think you use the same host?
If you connect with workbench with localhost and trying 184.168.27.82 then your php script will fail.

How have you stored your password in the script?
Is it ini file or coded in the php script. If coded in the php script and your password has any special character that modify literal string, such as '$', '\' will cause different password.
DerekTP123 5-Jun-19 11:14am
   
You say you can connect with .Net apps; are they running on the server (and therefore "local") or remote? When connecting, are you explicitly using username "mystrainfamily@184.168.27.82" or just "mystrainfamily"...? Check that user mystrainfamily has rights to connect from any server, not just from 184.168.27.82. Finally MySql has a couple of different password security protocols (sorry, can't remember the terminology right now); make sure your password is using the correct encryption for your connector. I know that's a bit vague but easy enough to google for.
BobbyStrain 5-Jun-19 12:25pm
   
The .NET apps are on the server and on my desktop. And no problem. I am using mystrainfamily for the username. My local PHP running on Apache gives the same error message, but, of course, a different IP address when I try to connect to the database on Godaddy. The connection to my local DB works fine. So I conclude that there is something different about Godaddy. Godaddy uses PHP 5.x and my PHP local install is 7.x. But the scripts are the same. I doubt I will get any help from Godaddy. My local Workbench connects to the Godaddy database OK, too. Using the same credentials.
DerekTP123 5-Jun-19 16:11pm
   
can you post the php code where you're trying to do the connect?
BobbyStrain 5-Jun-19 16:31pm
   
Here is the code for the connection.

$database_host = "mystrainfamily.db.1234567.hostedresource.com";
$username = "mystrainfamily";
$password = "Wxyz@";
$database_name = "mystrainfamily";


$con=mysqli_connect($database_host, $username, $password, $database_name)
or die("Error connecting to database: " .
mysqli_connect_error() . "");

echo "Connected to MySQL!";

mysqli_select_db($con, $database_name)
or die("Error selecting the database mystrainfamily: " .
mysqli_error() . "");

echo "Connected to MySQL, using database mystrainfamily.";
DerekTP123 6-Jun-19 5:13am
   
I assume you've followed the steps at https://uk.godaddy.com/help/connect-to-databases-remotely-in-cpanel-hosting-16103 (to explicitly allow access from your remote IP address) since you say you can connect to it via MySql Workbench... what happens if you run a php page on the GoDaddy webserver - can that connect?
BobbyStrain 6-Jun-19 10:51am
   
It does not connect from a PHP page on my Godaddy site either. And the other apps always work without fail. I'll have a look at the link you sent. There must be some security issue with Godaddy and PHP. Although Godaddy servers have PHP capability. My Wordpress works fine on the site.
DerekTP123 6-Jun-19 5:15am
   
Further to above reply, you need to check that you are connecting from a static IP address. Otherwise you might have temporarily been able to access the d/b using other tools but if your IP address has changed, php won't now connect. Use whatismyipaddress.com to verify your actual public IP address that GoDaddy will see.
BobbyStrain 8-Jun-19 19:25pm
   
I used the code to connect to a different MySql database on Godaddy with success. I think the problem I had was due to the password ending with @.
But I am not going to explore that avenue. Too many other apps connect to the database. Thanks for your help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100