Search code examples
phpmysqldrupaldrupal-7

PDOException: SQLSTATE[HY000]: General error: 3 Error writing file '/tmp/MYHKgYpv' (Errcode: 28)


I have installed Visitor Module Drupal 7. I have viewed the reports using www.domain.com/visitors. All the reports are working well. But when i view the user activity report it shows below error.

PDOException: SQLSTATE[HY000]: General error: 3 Error writing file '/tmp/MYHKgYpv' (Errcode: 28): SELECT u.name AS name, u.uid AS uid, COUNT(DISTINCT v.visitors_id) AS hits, COUNT(DISTINCT n.nid) AS nodes, COUNT(DISTINCT c.cid) AS comments FROM {users} u LEFT OUTER JOIN {visitors} v ON u.uid=v.visitors_uid LEFT OUTER JOIN {node} n ON u.uid=n.uid LEFT OUTER JOIN {comment} c ON u.uid=c.uid WHERE (visitors_date_time BETWEEN :db_condition_placeholder_0 AND :db_condition_placeholder_1) GROUP BY u.name, u.uid, v.visitors_uid, n.uid, c.uid ORDER BY hits DESC LIMIT 10 OFFSET 0; Array ( [:db_condition_placeholder_0] => 1451606400 [:db_condition_placeholder_1] => 1452556799 ) in PagerDefault->execute() (line 79 of /home/legalmon/public_html/includes/pager.inc).

How can i fix this issue?


Solution

  • You should continuously check your /tmp folder size while triggering "USER REPORT Query".

    If /tmp directory is 100% utilized you would experience this error.

    Solution is to mount some GB's to /tmp directory or set new location of MySQL tmp.

    To setting up New location:

    Create a directory anywhere you have enough space(can be the "/" root directory)
    
    # mkdir /home/mysqltmp
    
    Give write permissions
    
    # chmod 1777 /home/mysqltmp
    
    Open MY.CNF File
    
    # /etc/my.cnf 
    
    Add below line under the [mysqld] section and save the file
    
    # tmpdir=/home/mysqltmp
    
    Restart MySQL
    
    # /etc/init.d/mysql restart
    
    Check new location
    
    # mysqladmin var | grep tmpdir
    
    This should show following return.
    
    | slave_load_tmpdir                       | /home/mysqltmp
    | tmpdir                                  | /home/mysqltmp
    

    Done !!

    Try refresh the Page.