Ordering Post by Meta Key (Not Working)

Had same issue. Have spent like few hours searching for the problem and it turned out to be just a typo: instead of incorrect order_by you should use orderby – without the underscore. So, this should work:

$args = array(
    'post_type' => 'event',
    'meta_key'  => 'events_startdate',
    'orderby'   => 'meta_value',
  );

  $post_query = new WP_Query( $args );
  if( $post_query->have_posts() ) {
    while( $post_query->have_posts() ) {...}
  }

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