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;
My savings account
My retirement account
Winning the lottery
A Post-scarcity economy
Retirement?! You'll have to pull the keyboard from my cold, dead hands
I'm independently wealthy
Results (119 votes),