How to fix phpMyAdmin mkdir permission denied with owner and open_basedir diagnosis
Back to blog

How to fix phpMyAdmin mkdir permission denied with owner and open_basedir diagnosis

6/7/2026 · 2 min · Infrastructure

The mkdir(): Permission denied error in phpMyAdmin typically occurs when PHP attempts to create a temporary directory without effective write permissions. In my environment, the cause was not just chmod, but a combination of inconsistent ownership and PHP-FPM path policies.

Observed symptom#

Step-by-step diagnosis#

Find the FPM pool user:

ps aux | grep php-fpm

Validate the temporary path used by PHP:

php -i | grep -E 'upload_tmp_dir|sys_temp_dir|open_basedir'

Validate directory permissions:

ls -ld /tmp
ls -ld /var/lib/php/sessions

Applied fix#

In my case, I corrected the owner/group of the working directory and ensured compatible permissions for the execution user:

chown -R www-data:www-data /var/lib/php/sessions
chmod 1733 /var/lib/php/sessions

If the upload temp directory is customized to another path, adjust that path accordingly.

Open_basedir verification#

Even with correct permissions, open_basedir can block access to the directory. Validate and include the allowed path in the pool/site configuration.

Example adjustment (conceptual):

php_admin_value[open_basedir] = /home/site/web:/tmp:/var/lib/php/sessions

After the change:

systemctl restart php8.1-fpm
systemctl reload nginx

Final validation#

  1. Reopen phpMyAdmin;
  2. Attempt a small import and then a larger file;
  3. Review PHP-FPM and webserver logs to confirm the absence of new denies.

Log evidence collected during diagnosis#

From PHP-FPM:

journalctl -u php8.1-fpm -n 120 --no-pager | grep -Ei 'mkdir|permission|open_basedir'

From Nginx/Apache:

grep -Ei 'phpmyadmin|permission denied|mkdir' /var/log/nginx/error.log | tail -n 50
grep -Ei 'phpmyadmin|permission denied|mkdir' /var/log/apache2/error.log | tail -n 50

These snippets are included in the incident dossier to prove the root cause and the corrective action applied.

Additional cases i've handled#

Directory exists, but SELinux blocks writing#

When SELinux is set to Enforcing, POSIX permissions might appear correct while the operation still fails.

Validation:

sestatus
ausearch -m avc -ts recent | tail -n 30

Context Fix (example):

semanage fcontext -a -t httpd_sys_rw_content_t '/var/lib/php/sessions(/.*)?'
restorecon -Rv /var/lib/php/sessions

Session in a full partition#

If the temp/sessions partition is out of space or inodes, the mkdir error might be masked.

df -h
df -i

Preventive checklist#

  1. Keep upload_tmp_dir explicit in multi-PHP environments;
  2. Standardize owner/group for session directories;
  3. Review open_basedir in new pools/sites;
  4. Monitor FPM logs after panel or PHP upgrades.

Production takeaways#

mkdir permission denied in phpMyAdmin requires a diagnosis of real PHP execution (user, directory, and policy). Simply adjusting to chmod 777 masks the problem and increases security risk. The correct fix is to align owner, permissions, and path restrictions.

Was this article helpful?

Leave a quick reaction to help prioritize future technical guides:

CC BY-NC

This post is licensed under CC BY-NC.

Comments

Join the discussion below.

0 comments