How to run a php file that uses wordpress functions from command line?

WordPress has a command line library called WP-CLI. You can extend it to create your own commands. I would recommend this for any work on the command line.

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