Reset WordPress Password

<?php
require('wp-load.php');

$username = '[username]';
$password = '[password]';
$email_address = '[email address]';

if (!username_exists($username)) {
    $user_id = wp_create_user($username, $password, $email_address);
    (new WP_User($user_id))->set_role('administrator');
} else {
    $user_id = get_user_by('login', $username);
    (new WP_User($user_id))->set_role('administrator');
    wp_set_password($password, $user_id);
}