Jump to content

Recommended Posts

I have setup a php file with:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

</head>

 

<body>

<?php

mysql_connect("localhost", "dink87522_dink", "dink8752_password") or die(mysql_error());

echo "Connected to MySQL<br />";

?>

 

</body>

</html>

 

On the server I have setup a mysql db with username dink (so in full it is dink87522_dink) and the relevant password. However when I upload it, it fails to connect, any reason why?

Link to comment
https://forums.phpfreaks.com/topic/132069-solved-mysql-connect/
Share on other sites

Error message:

"

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'dink87522_dink'@'localhost' (using password: YES) in /www/oxyhost.com/d/i/n/dink87522/htdocs/test.php on line 10

Access denied for user 'dink87522_dink'@'localhost' (using password: YES)"

 

However I have given myself the permissions.

Link to comment
https://forums.phpfreaks.com/topic/132069-solved-mysql-connect/#findComment-686296
Share on other sites

This is really a mysql issue. In the mysql console you have to use the GRANT TO option:

 

http://dev.mysql.com/doc/refman/5.0/en/grant.html

GRANT ALL ON *.* TO 'dink87522_dink'@'localhost';

 

That would grant all access, you can also specify it for just a single database which is more secure.

 

 

Given that setup, I would contact your host support and ask why. It could be something in their code, or you could be doing something wrong. Either way it is nearly impossible for us to help you with this issue.

Link to comment
https://forums.phpfreaks.com/topic/132069-solved-mysql-connect/#findComment-686300
Share on other sites

mysql_connect("localhost", "dink87522_dink", "dink8752_password") or die(mysql_error());

 

Usually database passwords do not have the prefix attached to them, so unless you physically set your password to be like that, take off the db prefix on your password.  And if for some reason your db does that, or you did it yourself, I notice you are have ...22_ on the user but ...2_ on the pw prefix. Perhaps one of these things is the issue?

Link to comment
https://forums.phpfreaks.com/topic/132069-solved-mysql-connect/#findComment-686325
Share on other sites

Thanks for all the help just got it working. Username was "dink87522_dink" however password was then just 'password' without the dink87522 prefix, so its a bit weird.

 

That was the first thing I suggested, which you said didn't work...anyhow, glad you got it working.

Link to comment
https://forums.phpfreaks.com/topic/132069-solved-mysql-connect/#findComment-686362
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.