adam_blackice has asked for the wisdom of the Perl Monks concerning the following question:

i want to make a script to connect to a database stored in mysql : and here is the script >>
#!/usr/bin/perl -w use strict; use DBI; #step1- create connection objection my $dsn = 'DBI:mysql:firstDB'; my $user = 'adam'; my $password = 'no4vista'; my $conn = DBI->connect($dsn,$user,$password) || die "Error connecting +". DBI->errstr;
and the error is >>
root@adam-laptop:/home/adam/Desktop# perl db.pl DBI connect('firstDB','adam',...) failed: Access denied for user 'adam +'@'localhost' (using password: YES) at db.pl line 9 Error connectingAccess denied for user 'adam'@'localhost' (using passw +ord: YES) at db.pl line 9.
and iam sure of the user and he password on my system

Replies are listed 'Best First'.
Re: why this simple script return error ?
by rhesa (Vicar) on Apr 01, 2007 at 16:50 UTC
    and iam sure of the user and he password on my system
    Funny, your own database doesn't agree with you. MySQL is serious when it says: "Access denied for user 'adam'@'localhost' (using password: YES)".

    Check your username and password in MySQL; reset them if necessary. Then try again.

      thanx ..... i changed the user and the password from the mysql and it works :)
Re: why this simple script return error ?
by arc_of_descent (Hermit) on Apr 02, 2007 at 06:07 UTC

    Make sure you get the host part correct. MySQL authentication also looks at the host, apart from the username and password. Your code above, assumes that the host is localhost. But your database privileges might be otherwise.


    --
    Rohan

Re: why this simple script return error ?
by krikbugs (Novice) on Apr 01, 2007 at 22:50 UTC
    You need to set proper previleges to the user. Check the user table in mysql.mysql