Answers.Body: <p>Based on your comment, I see that each database only provides privileges to their respective user - and it seems implicit that you're using different users for each database.</p>
  
  <p>That means that your Drupal MySQL user doesn't have access to the CiviCRM database.  For Views to work properly, the Drupal user must have permission to run SELECT statements on the CiviCRM database.  From the documentation you linked: "If you have different database users for your CiviCRM and Drupal databases, then you need to grant SELECT access for the Drupal user to all the CiviCRM tables."</p>
  
  <p>Please try granting this access and try again, you should be good to go!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-05-09T04:09:07.697Z
Answers.LastActivityDate: 2016-05-09T04:09:07.697Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I am trying to implement Views, but when I want to create an elementary users view, I get the following error :</p>
  
  <p>SQLSTATE[42000]: Syntax error or access violation: 1142 SELECT command denied to user 'XYZ'@'localhost' for table 'civicrm_uf_match'</p>
  
  <p>This, though I followed the Wiki : <a href="https://wiki.civicrm.org/confluence/display/CRMDOC/Views3+Integration" rel="nofollow">https://wiki.civicrm.org/confluence/display/CRMDOC/Views3+Integration</a></p>
  
  <p>Here under is a partial copy of my settings.php file where I have copied the requested info :</p>
  
  <hr>
  
  <p>$databases = array (
    'default' => 
    array (
      'default' => 
      array (
        'database' => 'paroisse_drup275',
        'username' => 'xyz',
        'password' => 'abc',
        'host' => 'localhost',
        'port' => '',
        'driver' => 'mysql',
        'prefix' => 'dr_',
      ),
    ),
  );</p>
  
  <p>$databases['default']['default']['prefix']= array(
    'default' => 'dr_',
    'civicrm_acl'                              => '<code>paroisse_civicrm</code>.',
    'civicrm_acl_cache'                        => '<code>paroisse_civicrm</code>.',
    'civicrm_acl_contact_cache'                => '<code>paroisse_civicrm</code>.',
    'civicrm_acl_entity_role'                  => '<code>paroisse_civicrm</code>.',
    'civicrm_action_log'                       => '<code>paroisse_civicrm</code>.',
    'civicrm_action_mapping'                   => '<code>paroisse_civicrm</code>.',
    'civicrm_action_schedule'                  => '<code>paroisse_civicrm</code>.',
    'civicrm_activity'                         => '<code>paroisse_civicrm</code>.',
    'civicrm_activity_contact'                 => '<code>paroisse_civicrm</code>.',
  ... );</p>
  
  <hr>
  
  <p>I am in CiviCRM 4.7.6, with Drupal 7.43</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-05-03T13:08:24.097Z
Comments.Text: That error indicates a permissions problem.  Can you open MySQL (or PhpMyAdmin etc.) and post the results of the command: SHOW GRANTS FOR xyz@localhost;
  Also - my guess is that you're using separate MySQL users for Drupal and CiviCRM.  Can you run that "SHOW GRANTS" command for both the CiviCRM and Drupal MySQL user?
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-05-07T09:38:00.443Z
Comments.Text: Hi Jon, I actually use 2 different DBs. Not sure to understand what you ask : when I ask SHOW GRANT FOR ... to each user, I get the following answer : "#1044 - Access denied for user 'abcdef'@'localhost' to database 'mysql'" (where abcdef is my cPanel username) ; but if I ask ("MySQL DataBases" in cPanel) what privileges for each DB, each of them provide all privileges to their pertaining user (ALTER, CREATE, ..., SHOW VIEW, UPDATE) (18 privileges)
Comments.UserDisplayName: Jacques-Marie Moranne
Tags: <drupal-views>
Title: Views : Syntax error or access violation: 1142 (???)
ThreadText: # Views : Syntax error or access violation: 1142 (???)
  
  (Asked by: username_0 on 2016-05-02)
  
  I am trying to implement Views, but when I want to create an elementary users view, I get the following error :
  
  SQLSTATE[42000]: Syntax error or access violation: 1142 SELECT command denied to user 'XYZ'@'localhost' for table 'civicrm\_uf\_match'
  
  This, though I followed the Wiki : <https://wiki.civicrm.org/confluence/display/CRMDOC/Views3+Integration>
  
  Here under is a partial copy of my settings.php file where I have copied the requested info :
  
  ---
  
  $databases = array (
  'default' =>
  array (
  'default' =>
  array (
  'database' => 'paroisse\_drup275',
  'username' => 'xyz',
  'password' => 'abc',
  'host' => 'localhost',
  'port' => '',
  'driver' => 'mysql',
  'prefix' => 'dr\_',
  ),
  ),
  );
  
  $databases['default']['default']['prefix']= array(
  'default' => 'dr\_',
  'civicrm\_acl' => '`paroisse_civicrm`.',
  'civicrm\_acl\_cache' => '`paroisse_civicrm`.',
  'civicrm\_acl\_contact\_cache' => '`paroisse_civicrm`.',
  'civicrm\_acl\_entity\_role' => '`paroisse_civicrm`.',
  'civicrm\_action\_log' => '`paroisse_civicrm`.',
  'civicrm\_action\_mapping' => '`paroisse_civicrm`.',
  'civicrm\_action\_schedule' => '`paroisse_civicrm`.',
  'civicrm\_activity' => '`paroisse_civicrm`.',
  'civicrm\_activity\_contact' => '`paroisse_civicrm`.',
  ... );
  
  ---
  
  I am in CiviCRM 4.7.6, with Drupal 7.43
  
  **Tags:** drupal-views
  
  > **Comments:**
  > **username_1**: That error indicates a permissions problem.  Can you open MySQL (or PhpMyAdmin etc.) and post the results of the command: SHOW GRANTS FOR xyz@localhost; Also - my guess is that you're using separate MySQL users for Drupal and CiviCRM.  Can you run that "SHOW GRANTS" command for both the CiviCRM and Drupal MySQL user?  
  > **username_0**: Hi Jon, I actually use 2 different DBs. Not sure to understand what you ask : when I ask SHOW GRANT FOR ... to each user, I get the following answer : "#1044 - Access denied for user 'abcdef'@'localhost' to database 'mysql'" (where abcdef is my cPanel username) ; but if I ask ("MySQL DataBases" in cPanel) what privileges for each DB, each of them provide all privileges to their pertaining user (ALTER, CREATE, ..., SHOW VIEW, UPDATE) (18 privileges)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-05-09. Score: 1
  
  Based on your comment, I see that each database only provides privileges to their respective user - and it seems implicit that you're using different users for each database.
  
  That means that your Drupal MySQL user doesn't have access to the CiviCRM database. For Views to work properly, the Drupal user must have permission to run SELECT statements on the CiviCRM database. From the documentation you linked: "If you have different database users for your CiviCRM and Drupal databases, then you need to grant SELECT access for the Drupal user to all the CiviCRM tables."
  
  Please try granting this access and try again, you should be good to go!
  
  
  ---
  
  