Database works with console, fails otherwise

I can use database via script/console. Item.create and Item.find works
ok.
When I try to do the same thing on a test page, I get this error
message:

Mysql::Error: Lost connection to MySQL server during query: SELECT *
FROM items LIMIT 1

I suppose they both use the same settings, so what could be the reason
for this behaviour??

Got it working. Something needed updating and I didn’t get clear answer
what that was.