Error in phpMyAdmin after updating to v4.8.0: The $cfg['TempDir'] (./tmp/) is not accessible

113,268

Solution 1

Solution was to create a folder called tmp like this: /usr/share/phpmyadmin/tmp.

Also make sure that the user (or group) running the webserver (e.g. Apache) has write access to the newly created tmp folder. Consequently, change the ownership to that user or add write access for all users. The latter one might not be really advisable.

Solution 2

simple fix is to create tmp dir in your phpmyadmin dir and set permission to 777

mkdir tmp && chmod 777 tmp

then

update your config.inc.php file add that line

$cfg['TempDir'] = 'tmp';

Solution 3

I had this same problem on Ubuntu 18.04 when I replaced the phpMyAdmin version from the package repository (v4.6.6) with the latest version (4.8.0). I don't know if you are running on Ubuntu, but maybe my response will be helpful to you (or others) who encounter something similar.

I put the new version in the standard location, /usr/share/phpmyadmin/, but Ubuntu's package installation of PMA puts some configuration settings in other places (see /etc/phpmyadmin/ and /var/lib/phpmyadmin/). I found this setting in /etc/phpmyadmin/apache.conf:

php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp

and sure enough that directory had been created and had the proper permissions. Wanting to stay as close as possible to the package installation settings, I made this change in /usr/share/phpmyadmin/libraries/vendor_config.php and pointed directly to that folder:

//define('TEMP_DIR', './tmp/');
define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');

This setting is picked up by /usr/share/phpmyadmin/libraries/config.default.php (which you are not supposed to edit) to set $cfg['TempDir'].

Solution 4

In my case I added

$cfg['TempDir'] = '/usr/share/phpmyadmin/temp';

to the

config.inc.php File within the phpmyadmin folder

Hope it will help someone

Solution 5

Create a temp directory owned by and restricted to the webserver user. Do not place it inside of the phpMyAdmin webroot. (In this example, the webserver runs as apache):

mkdir -p /var/tmp/phpMyAdmin
chown apache:apache /var/tmp/phpMyAdmin
chmod 700 /var/tmp/phpMyAdmin

Next, set TempDir inside of phpMyAdmin's config.inc.php:

$cfg['TempDir'] = '/var/tmp/phpMyAdmin';

Any answer suggesting that you create /usr/share/phpmyadmin/tmp is advocating bad security practice. This is generally true for temp directories, and explicitly stated in the official phpMyAdmin documentation:

For security reasons, all directories should be outside the tree published by webserver.

Share:
113,268
David
Author by

David

Updated on July 05, 2022

Comments

  • David
    David almost 2 years

    phpMyAdmin worked fine with v4.7.9. Now after updating to v4.8.0 today (replacing the old phpmyadmin folder against the new one) I'm getting this message in phpMyAdmin:

    The $cfg['TempDir'] (./tmp/) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this.

    I added the folder ./tmp/ like like this: /usr/share/tmp

    phpMyAdmin is on: /usr/share/phpmyadmin

    This didn't change anything.

    Who know this error? What can I do?

  • Fabius
    Fabius about 6 years
    This seems not be not working on Amazon EC2 instance running AMI Linux with manually installed phpMyAdmin. I tried to give the whole /usr/share/phpmyadmin folder, subfolders and files chown and setfacl to apache group and even chmod 777 to /usr/share/phpmyadmin/tmp but still get error. The only way to make it work is to set $cfg['TempDir'] = '/tmp'; in config.inc.php but i'm not sure if this is the best way to manage it
  • David
    David about 6 years
    i'm not sure if this is the best way to manage it; I think it doesn't matter. It's okay to do it this way.
  • Oki Erie Rinaldi
    Oki Erie Rinaldi about 6 years
    I can't find config.inc.php. I only see the 'sample' of it.
  • David
    David about 6 years
    config.inc.phpshould be in phpMyAdmin folder. Maybe it's in /etc/phpmyadmin/config.inc.php?
  • Martin Schneider
    Martin Schneider about 6 years
    /var/www/pma# chown www-data tmp and any chmod 7__ did it
  • Fabius
    Fabius about 6 years
    Figured out it was due to SELinux. Tested it by giving chcon -R -t httpd_sys_rw_content_t /usr/share/phpmyadmin/tmp command, after chmod 777 /usr/share/phpmyadmin/tmp. No more errors reported on phpMyAdmin page. So i made the change permanent with semanage fcontext -a -t httpd_sys_rw_content_t "/usr/share/phpmyadmin/tmp(/.*)?" and rebooted. Ensured that the context was assigned proper permissions by checking tmp directory's line with ls -Z /usr/share/phpmyadmin | grep tmp. Error seems definitely gone.
  • Ishimwe Aubain Consolateur
    Ishimwe Aubain Consolateur about 6 years
    Remember to add required permissions if required.
  • ssaltman
    ssaltman about 6 years
    /usr/share/phpmyadmin/tmp (not temp) unless you added the folder that way
  • shanehoban
    shanehoban about 6 years
    Confirming it worked for me also on Ubuntu 18.04 - upgrading from 4.6.6 to 4.8.0
  • Ishimwe Aubain Consolateur
    Ishimwe Aubain Consolateur about 6 years
    folder was added just that way
  • skolind
    skolind about 6 years
    I did this, but added $cfg['TempDir'] = '/tmp'; to the config file.
  • Peter VARGA
    Peter VARGA almost 6 years
    You were right. I added it as feature request
  • Braconnot_P
    Braconnot_P over 5 years
    The default config is config.sample.inc.php, phpMyAdmin will work out of the box with this. Copy to config.inc.php to override it.
  • Deividson Damasio
    Deividson Damasio about 5 years
    @Fabius your comment about SElinux could be added in the reply. It work for me. Thank you.
  • suther
    suther about 5 years
    Additional to @Fabius comment (which work for me), I figured out, that this TempDir issue are also caused of symlink (in my case). I've created an symlink from phpmyadmin to current Version (phpMyAdmin4.xxx.xx). Thats let me easily switch the Version as long as I test the installation. If your vhost point to this symlink, phpmyadmin has trouble to found ./tmp. So do it like Fabius suggest, add the Variable to config.inc.php and all works as expected. Thanks Fabius.
  • user5248
    user5248 over 4 years
    ahhhh. nice. Worked like a champ.
  • TechnoCat
    TechnoCat over 4 years
    As per the suggestion from @skolind, the line for me was $cfg['TempDir'] = '/tmp';. Problem has now been fixed. Thanks!
  • William Ardila
    William Ardila about 4 years
    Also change define('CONFIG_DIR', ROOT_PATH); to define('CONFIG_DIR', '/etc/phpmyadmin/'); in the vendor_config.php file to get rid of the secret passphrase (blowfish_secret) error
  • KEMBL
    KEMBL about 4 years
    Centos8, after semanage changes, do not forget to apply them: restorecon -Rv '/usr/share/phpmyadmin/tmp'
  • Kevin C
    Kevin C over 3 years
    This is insecure, as you're giving other users the possibility to read the tmp files. This could lead to data being stolen.
  • Forever Cuber
    Forever Cuber about 3 years
    For permissions issues on the directories, 777 gives every user full access to the directory. All you really need to do is chown -R user:user ~/phpMyAdmin where user is the name of the webserver user serving PMA; i.e. www-data/nginx/apache. This will solve any ownership conflicts in the total installation including tmp, without giving permissions to everyone.
  • Timo
    Timo over 2 years
    @Fabius i'm not sure if this is the best way to manage it. Works for me, so keep cool, I understand that setting the tmp dir to /tmp works because the user who is logged in to pma is owner of /tmp .