How do I resolve ‘Database Error: Unable to connect to database’?

How do I resolve ‘Database Error: Unable to connect to database’?

If you’re receiving the message ‘Database Error: Unable to connect to the database: Could not connect to MySQL’, please make sure that the database name is correct and then try again.

The database name is the name displayed when you access your MySQL databases through cPanel.

The username is the main username that was shown on-screen when you first created the database.

The password is the main password that was shown on-screen when you first created the database unless you have since reset it.