Re: Access denied in remote mysql connection



wes.tibular@xxxxxxxxx wrote:

On Mar 5, 12:57 pm, Tim Greer <t...@xxxxxxxxxxxxx> wrote:
wes.tibu...@xxxxxxxxx wrote:
Forgive me if this is not the appropriate forum for this question.

I have installed DBI, and DBD::mysqlpp (couln't get DBD::mysql to
compile) on my system (with the requisite Net::MySql).  When i
connect to my local mysql database, things are fine.

When i attempt to connect to a remote mysql database, i get:

DBI connect('database=ossinv;host=remotehost','username',...)
failed: Access denied for user: '@localhost' (Using password: NO)
at /usr/

That seems to indicate there was no username passed. Also, it says
"localhost", yet you said this fails when you try to connect
remotely. Localhost is local (not remote), so your problem and
question are confusing.

@localhost is a redacted host name. it is what the remote connection
is returning in the error message

Be sure to paste the actual error message, or are you saying this very
literally was, showing @localhost with no username? That just doesn't
seem right is all.

Anyway, if the script connects fine locally, then it's
simply a matter of passing the right, existing host and database
names and login credentials, which probably isn't a Perl related
question.

It's a question about what the perl modules DBD::mysqlpp and
Net::Mysql are doing that leads it to not pass what i give them. In
the code, the username and password are being passed to mysqlpp, and i
have verified that Net:Mysql gets them, I have no control over what
happens from there, but it seems that the module is dropping it. Was
hoping to hear from someone using these modules that has seen the
problem before and can clue me in.

Thanks for the response.

Try using RaiseError, such as:

my $dbh = DBI->connect("dbi:mysqlPP:database=$db;host=$host",
$user, $password, { RaiseError => 1 }
);

That example, such as the one you posted as trying, seems to be correct.
If you can connect using mysql on the command line, then it should
work, provided it uses the default port (3306), if it's something else,
just pass the port= value.

Examples from the docs:

my $dsn = "dbi:mysqlPP:$database";
my $dsn = "dbi:mysqlPP:database=$database;host=$hostname";
my $dsn = "dbi:mysqlPP:database=$database;host=$hostname;port=$port";

my $dbh = DBI->connect($dsn, $user, $password);


So:

my $dbh = DBI->connect($dsn, $user, $password, { RaiseError => 1 });

Just to confirm, you can definitely connect from the command line with:

mysql -hHOST -uUSER database -pPASSWORD

from that system to the remote server?

<Also, please don't quote signatures, especially below your own text and
at the end of the post>

--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
.



Relevant Pages

  • Re: Help: Dreamweaver Database Conncetion Problem (PHP/MySQL)
    ... You probably can't connect to MySQL from outside the server, ... > on remote machines. ... you can't use Dreamweaver (or any other remote database tool) for ... I can upload my PHP site but the problem is that I ...
    (alt.php)
  • Re: php script to create mySQL database programmatically
    ... hosting configuration may not allow create database from script, ... Need working code to create database programmatically via PHP. ... Are you running this on the server with MySQL installed? ...
    (comp.lang.php)
  • Ruby DBI MySQL: how to specify protocol=tcp
    ... I'm using a ruby script to synchronize a remote MySQL ... database with a local database. ...
    (comp.lang.ruby)
  • Base table fields have been changed - Error using remote views an
    ... I am using a database which is filled with remote views that connect to a MySQL db via ODBC. ... I created the views manually and they seem to work quite fine, but everything changes when i connect to another MySQL database. ...
    (microsoft.public.fox.vfp.dbc)
  • MYSQL Server has gone away
    ... I've using a remote view to send a large piece of data 'about 5MB' to the ... The MYSQL documentation seems to suggest the database could be timing out ... I assume it's more to do with the packet size but don't know how to prove ...
    (microsoft.public.fox.programmer.exchange)