Paul DuBois wrote:

At 5:18 -0500 6/2/04, [EMAIL PROTECTED] wrote:

There's got to be something else wrong. I've got the exact same problem and
I have done a chmod 666 on the directory I am trying to write to with no
luck. I am running v4.0.15


Mode is not enough, you must consider ownership.

Huh? I don't understand what you are saying here.

Remember, *you* are not trying to write the file.  The MySQL server
(mysqld) is trying to write the file, and it might not be running
under your user ID.  It's probably running from the "mysql" account.

Right. The server, running as user mysql, writes the file, so the mysql user must be able to write a file in the target directory. This does not require ownership, however, only the correct set of permissions.


To do anything in the destination directory, the mysql user must have execute permission on every part of the path. In the case of the original poster, where we want to write a file in /Users/johnmistler/Desktop, mysql must have execute permission on /, /Users, /Users/johnmistler, and /Users/johnmistler/Desktop just to be able to cd (change directory) to /Users/johnmistler/Desktop. Once there, it must have write permission to create a new file. Usually, the path to one's home directory is executable by everyone by default, so giving write permission to the subdirectory is enough. If, however, the targetdir is more than one level below home, you'll probably have to add execute permission to the intervening directories as well.

This is why `chmod 666 targetdir` does not work. It gives everyone permission to read and write targetdir, but it removes execute permission. Without execute, you cannot cd into targetdir, rendering write permission useless. Instead, you should do `chmod 733 targetdir`. This gives execute and write permission to everyone, but reserves read permission to targetdir's owner. Thus, mysql will be able to cd to targetdir and write a file (as will anyone else), but only targetdir's owner will be able to list the contents of targetdir (the point of read permission), which adds a teeny bit of security.

As an example, if targetdir is the /path/to/home/mysqlstuff/proj1/outfiles directory, you will probably need to

  chmod 755 mysqlstuff
  chmod 755 mysqlstuff/proj1
  chmod 733 mysqlstuff/proj1/outfiles

If you have the power to set targetdir's group to mysql, (assuming mysql runs as user=mysql, group=mysql), you can drop the world permissions in favor of just the group permissions.

  sudo chgrp mysql targetdir
  chmod 730 targetdir

That would be an improvement in terms of security, since it further limits access to targetdir.

Michael




-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to