pphoa Posted February 25, 2003 Posted February 25, 2003 I have a simple perl CGI script which uses the DBI module and tries to connect to my first-ever MySQL database, but I get this error from connect(): Access denied for user: 'user@localhost' to database 'dbname' ('user' and 'dbname' not the real ones). I believe this error message means that the user and password is correct. Sample code: my $db = 'DBI:mysql:dbname:localhost'; my $dbh = DBI->connect($db, 'user', 'password'); Any advice? Quote
rayners Posted February 25, 2003 Posted February 25, 2003 Did you use 'user' and 'database' or 'tchaccountname_user' and 'tchaccountname_database'? Quote
pphoa Posted February 26, 2003 Author Posted February 26, 2003 Thanks for your response. Indeed, I did specify the account name as you suggest. my $db = 'DBI:mysql:pphoa_database:localhost'; my $pass = 'this is not the real password'; my $dbh = DBI->connect($db, 'pphoa_user', $pass) || print "$DBI::errstr"; And I get when viewing the page: Access denied for user: 'pphoa_user@localhost' to database 'pphoa_database' I believe the user/password information is correct since if I change either of them to something stupid then I get a more obvious password verification problem. Quote
rayners Posted February 26, 2003 Posted February 26, 2003 And you have explicitly given the username access to the database? CPanel doesn't set that up by default. Trips me up sometimes. Quote
waynej Posted February 27, 2003 Posted February 27, 2003 (I am the same person as pphoa) "And you have explicitly given the username access to the database?" Well, I go to the "Manage Mysql" area on the cpanel, called "Sql Account Maintenance" once you get there. I see my database name and the user name. Hey, there's a "Add User to Db" button. Wouldn't you know, IT WORKS! Thanks for your help! Sorry if I wasted your time if I led you to believe I was knowledgeable. Quote
rayners Posted February 27, 2003 Posted February 27, 2003 No time was wasted. I'm glad I could help. I had the same problem myself when I first started here. I hadn't a clue why MT wouldn't install, until I started wandering through CPanel. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.