By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,278 Members | 1,086 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,278 IT Pros & Developers. It's quick & easy.

can't connect to the remote MySQL db

P: 76
can anyone tell me what am i doing wrong here. i'm trying to connect remotely to the MySQL database on a server (SunOS multivac 5.9 sparc SUNW,Sun-Fire-V240). i know that the username and the password are correct, but it keeps giving me this error:
DBI connect('mydb:myhostname:1234','username',...) failed: Access denied for user 'username'@'' (using password: YES) at line 5
Error: Access denied for user 'username'@'' (using password: YES)

i would appreciate your help.

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  3. use DBI;
  5. my $dbh = DBI->connect ("DBI:mysql:mydb:myhostname:1234","username","password") or die "Error: $DBI::errstr\n";
  6. my $sql = "SELECT info FROM mytable limit 2";
  7. my $in = $dbh->prepare($sql);
  8. $in->execute;
  10. print "Content-type: text/html \n\n";
  11. print STDOUT "$in\n";
Oct 13 '07 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 801
You must have to GRANT permissions to user username to connect remotely.
Nov 6 '07 #2

P: 1
...which is cause of security-point.. disabled ;) (networking disabled)

to "bypass" that, you could use Putty to make a port-tunnel, so your script would connect to to port xxxx which just forward you trought putty-tunnel into remote machine and connect there as "localhost" which is normaly not restricted..
(for this case u should have a shell access to the remote machine!)
if not, then ...just put the php on the remote machine (since u have sql access, u should have ftp access too, else you have got a real problem ^^)

guide for putty:(
Configuration -> Connection -> SSH -> Tunnels
add there in "source port" the port your php script is using, normaly 3306
in Destination add sth like and let protocol and direction both at "auto"
then just click add vóila XD , connect per ssh to the shell, now u can start your php script on your local machine (where u changed the host to XD) and it will work

Nov 9 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.