How to show a random selection of posts from the search

This is easy to do using the pre_get_posts action hook to set the orderby to rand in the query, something like this:

function random_search_result( $q ) {
    if ( is_search() && is_main_query() )
        $q->set( 'orderby', 'rand');
}
add_action( 'pre_get_posts', 'random_search_result' );

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