Database Error on install

I am trying to install OJS 3.1.1-4 so that I can restore a backup. I have formatted a 32GB card, installed Apache/PHP/MySQL, created a db and user in mysql, downloaded the OJS tar, unzipped and run php tools/install.php. I get an error

Database connection failed!

ojs2: Database connection failed!

Any ideas on what might be wrong?