Making plugin to use different table prefix cause permission problem

You will need to restore the database prefix after using it , with something like this

global $wpdb;
$previousPrefix=$wpdb->prefix;
$wpdb->prefix="mainsiteprefix_";
//Database access goes here
$wpdb->prefix=$previousPrefix;

or you can create a new wpdb object like this:

$wpdb2 = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST );

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