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;
Bought a souvenir
Emailed all my friends about it
Got blowed up
Hit him right dead in the jaw
Made it awkward
Took a selfie
Want to go home
Results (417 votes). Check out past polls.