Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7921571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:37:47+00:00 2026-06-03T16:37:47+00:00

I have a Perl script which retrieves data from MySQL Database. this is the

  • 0

I have a Perl script which retrieves data from MySQL Database. this is the code:

sub startSession{
    my $self = shift;

    my $dsn = "dbi:".$self{platform}.":".$self{database}.":".$self{host}.":".$self{port};
    print "$dsn\n" ;
    $self{dbHandle} = DBI->connect($dsn,$user,$password);   
}

I have provided every information from an external file. I get the error message

DBI connect('dbname:**.**.**.**:3306','',...) failed: Access denied for user 'root'@'dbserver' (using password: NO) at line 89

Can't call method "prepare" on an undefined value at at line 97

I am very sure the root can connect from any host and the password is also correct.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:37:50+00:00Added an answer on June 3, 2026 at 4:37 pm

    First, your immediate problem, is as @Sinan Ünür says, that you need to change $self{platform} to $self->{platform}, etc.

    Your second immediate problem is that it appears you’re getting $user and $password from nowhere (they are not passed to the function, so they are undefined unless they are global variables), which would explain the using password: NO part of the error. Maybe those should be $self->{user} and $self->{password}?

    You should considering put this at the top of your module, at least during development, to automatically catch errors like these:

    use warnings qw(all);
    use strict;
    

    But I’d also comment, that from a design perspective, you really ought to treat DSNs as opaque strings. Each database has its own DSN format. So if you ever want to target a different database, you’ll need a different DSN format. Or, possibly, someday MySQL will use a different format (it already has two). Either way, it’ll be much easier to change it one place, in a configuration file, than to track down each place you concatenate the various pieces together.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a perl script which is used to process some data files from
I have a Perl script that contains this code snippet, which calls the system
I have a Perl script which forks a number of sub-processes. I'd like to
I have a Perl script which downloads a large number of files from a
I have this Perl script which is used to sort packages based on package
I have written a Perl CGI script which fetches an html page from a
I have to code some kind of (perl) script which queries a Facebook wall
I have a perl script which when run from the command line generates a
I have a Perl script which nests foreach loops as seen below. It takes
I have a Perl script which will allow for a file to be uploaded

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.