Can you connect to your database from the command line client for mysql:
# mysql -u www-data -p moodle
If not something's wrong with your database setup.
Installing and upgrading help
Cannot connect to database.
This discussion has been locked so you can no longer reply to it.