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
hi,
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'@'compname-345-56.abcd.edu' (using password: YES) at myscript.pl line 5
Error: Access denied for user 'username'@'compname-345-56.abcd.edu' (using password: YES)

i would appreciate your help.


Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. use DBI;
  4.  
  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;
  9.  
  10. print "Content-type: text/html \n\n";
  11. print STDOUT "$in\n";
  12.  
Oct 13 '07 #1
Share this Question
Share on Google+
2 Replies


mwasif
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 127.0.0.1 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 127.0.0.1:3306 and let protocol and direction both at "auto"
then just click add ..et 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 127.0.0.1 XD) and it will work
);

regards
cracky
Nov 9 '07 #3

Post your reply

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