How can I rename roles in a WordPress multisite installation?

I have made minor changes which can help you in achieving your desired results. We need to use network_admin_menu hook instead of init and also updated the condition of checking if the roles exist.

<?php
function wpmudev_custom_change_role_names_multisite() {
    // Here we are getting the roles of the network.
    $wp_roles = get_site_option('wp_user_roles');

    // Here we are checking if the roles exist.
    if ( isset( $wp_roles['administrator'] ) && isset( $wp_roles['editor'] ) ) {
        // Change the names
        $wp_roles['administrator']['name'] = 'Owner';
        $wp_roles['editor']['name'] = 'Creador de Contenido';

        // Here we have updated the roles in the network.
        update_site_option('wp_user_roles', $wp_roles);
    }
}
add_action('network_admin_menu', 'wpmudev_custom_change_role_names_multisite');

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