In this case all the database related issues have to be checked.
1. Temp partition should not be full.
2. The files where the error is getting have to be checked for ownership(mysql.mysql) and permission(700).
3. Should be used mysql_connect() instead of mysql_pconnect().
4. The file which set Mysql connections has to be checked for dbuser, dbpass, dbname etc.
5. If accessing database remotely then add % sign in cpanel>>mysql>>access hosts.
6. Restarting mysql service.