0

PDOException: SQLSTATE[HY000]: General error: 1 Can't create/write to file '/tmp/#sql_e0f_0.MYI' (Errcode: 13): SELECT DISTINCT SUBSTRING_INDEX(source, '/', 1) AS path FROM {url_alias}; Array ( ) in drupal_path_alias_whitelist_rebuild() (line 380 of /var/www/html/includes/path.inc).

After noting report status for updating .htaccess in this tmp folder i found in root directory I then changed permissions to 755 and ownership apache:apache also tried owner:apache Anyway, when tested and trying to delete content as admin it throws above error.

UPDATE: All of this occurred due to erroneous status report for drupal 7.24 saying needing to add security update to files and tmp folder .htaccess but it is a bogus bug and you need to delete them then run cron will recreate and status report disappears.

SEE http://www.ostraining.com/blog/drupal/drupal-724-tmp-directory/

problem solved

2

4 Answers 4

2

You need to find the user your server is running with (or the owner of files and folders). If your drupal is working correct besides this error then go to your website root and type ls -l in terminal. It will show you something like this:

-rw-rw-rw-  1 www-data charlie 6604 aug  8 04:04 authorize.php
drwxrwxrwx  3 www-data charlie 4096 nov 12 13:02 cgi-bin
etc.

Here you see the owner (www-data) and the group (charlie). This can be different on your system, but remember which you have for the chown-command below.

Give your /tmp folder the same owner. Go to /admin/config/media/file-system on your site and see the path to your tmp folder. If it starts with a '/' then it's located in the root of your system. If it doesn't start with a '/' then its relative to your website-folder, tmp for example is then really /var/www/httpdocs/tmp.

Then use chown -R www-data:charlie /path/to/tmp and you should be good to go. When you use your systems tempfolder at /tmp you really should create and set a subfolder inside /tmp.

7
  • I'm in major trouble now- there are a million ppl saying diff things for ownership and permissions! I don't know if it should say apache:apache or root:apache for all my drupal install. I followed command line instructions on drupal documents but i think it was for shared hosting so now EVERYTHING is wrong :(
    – cea
    Dec 14, 2013 at 7:50
  • And I still can't get my head around the basics of security to figure it out myself :((( which is really what I need to study!!! but for now I am completely locked out
    – cea
    Dec 14, 2013 at 7:51
  • how do I set all folders and files in drupal pre existing install to correct ownership? please
    – cea
    Dec 14, 2013 at 7:59
  • There is not one configuration that is correct for shared hosting. See the accepted answer this question to learn how to figure this out: What are the most appropriate users and permission levels for Drupal sites on shared hosting? Dec 14, 2013 at 8:13
  • 'lsof -i | grep apache' gives you the apache-user in 3rd column (ignore the output wich gives root in 3rd column. chown -R 'apache-user' /path/to/drupalfolders. There is no need for using chmod by default (on default setups), and really never use 777 as it's insecure by default.
    – Marcel
    Dec 14, 2013 at 8:56
1

Two possible issues there, disk space or write permissions.

Disk space

You could out of disk space in the /tmp folder, try

df -h

to list disk free space. Your query could be very large if many url aliases to process.

Write permissions

The error isn't actually apache / php but rather a mysql error. The query is trying to write to the /tmp folder to store additional temporary data. You need to make sure the /tmp dir is also writeable by the mysql user. Easiest way is

sudo chmod 777 /tmp

Alternatively, you could make it 775 (recommended) and add the mysql user to the same ownership group for write access.

3
  • isn't 755 recommended?
    – cea
    Dec 14, 2013 at 12:27
  • @GisleHannemyr I suggested 775, not 755. Write access for allowed group, read access for others Dec 14, 2013 at 20:56
  • Thanks David and Gisle for clearing that up- I will change to 775
    – cea
    Dec 15, 2013 at 0:20
0

I usually do it like this (if I have a FTP access to my project):

  1. Create a new tmp or temp directory in root folder of my drupal installation;
  2. Give it 777 permission (what owner is not matter I think);
  3. Open admin->configuration->file-system;
  4. Enter my recently created folder name to Temporary folder input field (WITHOUT ANY SLASHES);
  5. It's done;
0
0

I had this issue and removed the forward slash from it and it worked, took me hours to work that out. It was "/tmp" and I changed it to 'tmp'. Thought I should mention just in case.

1
  • Yes I know about that but this was an all day problem that had to do with buggy status report however I got a great grounding in ownership and permissions!
    – cea
    Dec 15, 2013 at 0:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.