How to programmatically set existing image in media library the featured image for a post in wordpress

How to programmatically set existing image in media library the featured image for a post in wordpress

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)