0

So I am using Perl DBI module to access MySQL database on a server linux machine, which I do not have root access. The admin installed the MySQL and create a database for me. I can write a Perl script to access the database just fine.

Then I installed MySQL in my local space and change environment variable to use the locally installed mysql executables. I can access the database from command line. But after I change the Perl script accordingly and execute it, I got "Access denied" error. And it seems the Perl script still try to use the admin installed mysql to access.

So how can I solve this?

Here's how I connect:

my $conn = DBI->connect("dbi:mysql:dbname:localhost:3366", "root", "root")
    or die DBI::errstr;
0

2 Answers 2

1

I found the solution so I'll answer my own question.

What I did is to re-compile and install perl DBD-mysql module and give it the path of the locally installed mysql.

perl Makefile.PL PREFIX=/path/to/perl/local/lib 
             --mysql_config=/path/to/locally_installed_mysql/bin/mysql_config

Reference: http://cpansearch.perl.org/src/RUDY/DBD-mysql-2.9008/INSTALL.html

Sign up to request clarification or add additional context in comments.

Comments

0

Use single quotes generally in database connection string, password string and sql query,because these might give you error with double quotes.As double quotes is used for interpolation.

So please try with single quotes.

my $conn = DBI->connect('dbi:mysql:dbname:localhost:3366', 'root', 'root') or die "..."

I am assuming that you have access to mysql with root user with password through command line (manually) as you stated.

1 Comment

I have tried single quotes as you suggested, but it does not work for me. I have root access only to my locally installed mysql.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.