Web Hosting Forum | Lunarpages

Author Topic: Perl/mySQl connection: "Access Denied"  (Read 23397 times)

Offline kxssys0

  • Space Explorer
  • ***
  • Posts: 6
Perl/mySQl connection: "Access Denied"
« on: November 13, 2014, 06:50:48 PM »
I'm failing to connect remotely to mySql database, with error "Access denied for user '<myuserid>', using a perl script.

I think I am following the information in the tutorials:

"hostname: Your Host Name
 user: serverprefix_username
 database name: serverprefix_databasename
 password: the database user's password
"

I've checked the password is correct and even reset it just in case, the user is granted access to the database and the names seem to match what was sent to me in my 'welcome email'.

My code is fairly standard, matching code that people have posted:

my $host = "lpsql03.lunariffic.com";
my $driver = "mysql";
my $database = "kxssys0_db";
my $dsn = "DBI:$driver:database=$database;host=$host";
my $userid = "kxssys0_admin";
my $password = "<mypassword>";
my $dbh = DBI->connect($dsn, $userid, $password ) or die $DBI::errstr;

So I am stumped. Any ideas?  Thanks.

Online MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6210
Re: Perl/mySQl connection: "Access Denied"
« Reply #1 on: November 14, 2014, 08:32:25 AM »
(Note that it is not a good idea to give out your Lunarpages account name (what you called "serverprefix"), as if someone can find your user name and password, they will have unlimited access to your database. However, at this point, that's water under the bridge.)

Are you able to use this database from other languages or applications? That would indicate that you have the right database host, username, password, etc., and it's something peculiar to your use of Perl that's the problem. Note that the "hostname" is your database host (lpsql03.lunariffic.com), not the site host. Everything looks OK in the code you gave, although I haven't used Perl + MySQL on Lunarpages myself, so I might have missed something. You might confirm that "mysql" is the correct driver (maybe it's mysqli now, or something including "DBI"?). How old is the tutorial or other code examples that you are basing your code on? I know that with PHP, use of MySQL is discouraged (use MySQLi or DBI libraries). You also might confirm that you still have the right DB server name, and it wasn't changed/reassigned recently by LP.

If this username is unique to your Perl work, did you remember to grant it the appropriate privileges in your control panel?
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline kxssys0

  • Space Explorer
  • ***
  • Posts: 6
Re: Perl/mySQl connection: "Access Denied"
« Reply #2 on: November 14, 2014, 02:28:14 PM »
I'm pretty sure all the code in the perl script is correct because I tested database connection and several type of table updates with it on my local computer. Then I changed the connection information to perform the same updates on LP and get the error.

It is true that maybe LP has a different version of MySql requiring some other driver name. I will check that.

My script is using the 'DBI' library. The hostname is indeed my database host, and is accurate given that I just copy/pasted it from my welcome email from 2 weeks ago into my code.  I did grant my userid access to the DB. 

It frustrates me a bit that there's no clue such as "database is correct, but your XYZ is not found." (etc) Wouldn't that be nice?

Thanks for replying.

Offline kxssys0

  • Space Explorer
  • ***
  • Posts: 6
Re: Perl/mySQl connection: "Access Denied"
« Reply #3 on: November 14, 2014, 02:39:54 PM »
One more detail about the error message:
'Access denied for user "<myuser'@ool-ad021a93.dyn.optonline.net' (using password:YES)

Why does 'optonline.net' have anything to do with this? It happens to be my email account, but I'm just running the script from a command line.  Bizarre...maybe my computer has some firewall to relax?  Hmmmm

Offline kxssys0

  • Space Explorer
  • ***
  • Posts: 6
Re: Perl/mySQl connection: "Access Denied"
« Reply #4 on: November 14, 2014, 02:49:39 PM »
Since I am totally new to database web hosting - I'm wondering if the SQL server has to be started in order for clients to submit connection requests successfully? And if so, how does one start the DB server on the server? Is there command line access in any way to enable me (the Admin user) to do it? Thanks.

Online MrPhil

  • Senior Moderator
  • Berserker Poster
  • *****
  • Posts: 6210
Re: Perl/mySQl connection: "Access Denied"
« Reply #5 on: December 03, 2014, 08:36:43 AM »
If you're on a shared server, you should not have to do anything to start the SQL server. VPS/cloud and dedicated, it depends on whether you are managing the server, or you're sharing one with other customers.

I've never tried remote database access, but my guess would be that you have some sort of permissions problem (access privileges granted to a user). Is your "myuser" at your address registered as a user, with password and appropriate privileges? If you are not expecting it to use that email address, but another ID+password that you've defined, you might not be accessing the server correctly (giving an ID in the right place). I think the subject of remote DB access has been discussed from time to time, so be sure to search for all references in this forum and see if there's anything else to try.
Visit My Site

E-mail Me
  
-= From the ashes shall rise a sooty tern =-

Offline mithcd

  • Intergalactic Superstar
  • *****
  • Posts: 133
Re: Perl/mySQl connection: "Access Denied"
« Reply #6 on: December 16, 2014, 09:40:28 AM »
Hi kxssys0,just to confirm, is this on a shared or dedicated servers?

 

Share |