How to get hierarchical number of custom taxanomy

You can use get_ancestors() to get an array of parents, which you can then count.

$term_id = 42;
$ancestors = get_ancestors( $term_id, 'category' );
if( ! empty( $ancestors ) ){
    echo count( $ancestors );
}

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