After installing apache-mysql-php on Debian. I can't import .sql
files to MySQL through phpMyAdmin. Error says:
Uploaded file cannot be moved, because the server has open_basedir enabled without access to the /tmp directory (for temporary files).
open_basedir
is commented in both /etc/php5/apache2/php.ini
and /etc/php5/cli/php.ini
and safe_mode is OFF.
I set 777
permission to /var/tmp
still get the error.
While you say that open_basedir
is commented out, what is the output of phpinfo()
? There should be an open_basedir
setting in there. And perhaps there is an .htaccess
file—or another php.ini
config—that is setting open_basedir
somewhere. That said, according to the official phpMyAdmin docs :
Since version 2.2.4, phpMyAdmin supports servers with open_basedir restrictions. However you need to create temporary directory and configure it as $cfg['TempDir']. The uploaded files will be moved there, and after execution of your SQL commands, removed.
So while you say that open_basedir
is commented out—implying it is not being used—perhaps you should open up your phpMyAdmin config and set the cfg_TempDir to point to /var/tmp
. The config.php
file is located here in Ubuntu 12.04:
/usr/share/phpmyadmin/config.inc.php
Note that the error message refers to /tmp/
but you are referring to /var/tmp/
.
Additionally, the issue seems to be covered here in the community wiki reference for PHP related error:
The fix is normally to change the PHP configuration, the related setting is called open_basedir.
Sometimes the wrong file or directory names are used, the fix is then to use the right ones.
So in your case you can perhaps adjust the php.ini
to have this setting:
open_basedir "/var/tmp/:/tmp/:/"
And note that the only php.ini
that matters in a case of web related issues like this is /etc/php5/apache2/php.ini
. The CLI php.ini
located here /etc/php5/cli/php.ini
is strictly for CLI use and has nothing to do with the Apache PHP module.
I had the same problem and solved as follows:
I opened the file /etc/phpmyadmin/apache.conf and found a tag with parameters inside. The last one was open_basedir
php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/
I simply prepend /tmp/: and that solved my problem
php_admin_value open_basedir /tmp/:/usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/
of course I had to restart apache after that, but that was all.
This is a problem of the php.ini
file. The problem is that the open_basedir
is not set. You must set it in php.ini
and also set the upload_tmp_dir
to be under the open_basedir
.
There is the same problem in Windows. Can be solved by setting ie open_basedir = C:\\Apache24\\htdocs
(use your path to htdocs folder) and upload_tmp_dir = C:\\Apache24\\htdocs\\tmp
.
An addendum to Viter Rod's answer above is that you also have to grant full access to the tmp folder. So run:
sudo chmod 777 tmp/
It should work after that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.