access denied for user 'root'@'localhost' (using password yes) while connecting perl with mysql -
i had written following perl script connect mysql workbench database, giving error access denied user 'root'@'localhost' (using password yes)
.
error after running code:
c:\users\1053130\desktop>perl mysql.pl dbi connect('database=dvd_collection','root',...) failed: access denied user 'root'@'localhost' (using password: yes) @ mysql.pl line 9. access denied user 'root'@'localhost' (using password: yes) @ mysql.pl line 9.
i have gone through similar questions also, according these have username
, password
. changed root password also. error still same.
code:
#!/usr/bin/perl use dbi; use strict; $driver = "mysql"; $database = "dvd_collection"; $dsn = "dbi:$driver:database=$database"; $userid = "root"; $password = "123"; $dbh = dbi->connect($dsn, $userid, $password ) or die $dbi::errstr;
shouldnt my $dsn = "dbi:$driver:database=$database";
rather be
my $dsn = "dbi:$driver:database=$database;host=$hostname;port=$port";
?
missing host , port?
edit:
says access denied for... @localhost. local server? if not, should declare server-details shown above.
edit2:
according comment should check password, simple sounds. can go mysql -u root -p newpasswordhere
. choose new 1 , retry.
edit3:
changed password, try following change of connect:
my $dbh = dbi->connect('dbi:mysql:dbname=dvd_collection;host=localhost','root', '123') || die "could not connect database: $dbi::errstr";
i've seen ppl having issues different formats of connection.
Comments
Post a Comment