in reply to connect to DBD::MYSQL
Did you try to replace localhost with 127.0.0.1?
edit (added question): Is the error really 'Unknown MYSQL server host ' localhost' <11004>', as in '<space>localhost? Could it be your code is not actually what you pasted, and the is a space before $hostname?
# create table (name char(20));
CREATE USER 'test_user'@'localhost';
GRANT ALL PRIVILEGES ON * . * TO 'test_user'@'localhost';
select * from ttt;
An Englishman in New York
An American Werewolf in London
An American in Paris
The Innocents Abroad
An Idiot Abroad
Robinson Crusoe on Mars
A Connecticut_Yankee in King Arthur's Court
There and Back Again
Travels into Several Remote Nations of the World
Results (75 votes). Check out past polls.