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 electronic device
Being the designated driver
Spending time with a celebrity
I never won anything
I never play the lottery
I haven't checked my spam folder recently
Results (393 votes). Check out past polls.