How can I purge all post revisions except the latest 5?

Please take database backup and run a below MYSQL query and check is this helpful:

DELETE FROM wp_posts WHERE post_type = “revision” AND ID NOT IN(SELECT ID FROM wp_posts WHERE post_type=”revision” ORDER BY ID DESC LIMIT 5)

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