How To connect to the same WordPress database with different database user

The solution for this is to call a function that will initialize the wpdb object properties. which is wp_set_wpdb_vars.

After you instantiate the wpdb object call that function.

$wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
//Set the database table prefix and the format specifiers for database
wp_set_wpdb_vars();