Recheck all $CFG->db* parameters in your config.php.
Some common mistakes:
- $CFG->dbtype, ist it the correct one out of mysql, mysqli, mariadb, etc?
- Can you log in to mysql console with $CFG->dbname, $CFG->dbuser, $CFG->dbpass and look at the content of the Moodle database?
- Is $CFG->prefix there in every table?