Bug #2028 source compiles but does not run due to permissions problems
Submitted: 5 Dec 2003 22:45 Modified: 5 Dec 2003 23:57
Reporter: [ name withheld ] Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:mysql-4.0.16 (Source distribution) OS:Linux (Linux first 2.4.19 i686)
Assigned to: CPU Architecture:Any

[5 Dec 2003 22:45] [ name withheld ]
Description:
I downloaded and compiled without problems:

# ./configure
# make
# make install
# scripts/mysql_install_db
# /usr/local/bin/mysqld_safe &

But I always got this message:

  Starting mysqld daemon with databases from /usr/local/var
  031205 22:50:14  mysqld ended

Eventually I found the log file and read this message:

  031205 22:50:14  mysqld started
  031205 22:50:14  InnoDB: Operating system error number 13 in a file operation.
  InnoDB: See http://www.innodb.com/ibman.html for installation help.
  InnoDB: The error means mysqld does not have the access rights to
  InnoDB: the directory.
  InnoDB: File name ./ibdata1
  InnoDB: File operation call: 'create'.
  InnoDB: Cannot continue operation.
  031205 22:50:14  mysqld ended

So I new it was a permissions problem, but I couldn't figure out where.
Reading on the web about other people having this same error message, I came across the hint of configuring /etc/my.cnf and uncommenting the sections regarding InnoDB.  I also changed the references to "/usr/local/var" to "/usr/local/var/mysql".  While this didn't solve the problem, it made the error message considerably clearer:

  031205 22:59:06  mysqld started
  031205 22:59:06  InnoDB: Operating system error number 13 in a file operation.
  InnoDB: See http://www.innodb.com/ibman.html for installation help.
  InnoDB: The error means mysqld does not have the access rights to
  InnoDB: the directory.
  InnoDB: File name /usr/local/var/mysql/ibdata1
  InnoDB: File operation call: 'create'.
  InnoDB: Cannot continue operation.
  031205 22:59:06  mysqld ended

Once I knew that the file was trying to be created in /usr/local/var/mysql, I quickly figured out that my directory "/usr/local/var" was set up "drwx-----    1 root     root".   Once I gave read/execute priveleges to group and other, things worked fine.

How to repeat:
You might be saying, that is a user error, and not a bug.  But I've compiled and installed MySQL for about as long as it has existed, and yet I still wasted an hour trying to figure out what was happening.   And I still don't know if the original error was trying to create a file in "/usr/local/var" (as implied by the commented out portion of the my.cnf file) or in "/usr/local/var/mysql".

Suggested fix:
Improving that first error message would be great.  Perhaps it could be changed to say:  "The error means the mysqld user 'mysql' does not have access rights to the directory '/usr/local/var/mysql'".  And the "./ibdata1" could be expanded out to show the full path.  Also, if InnoDB is being used by default, perhaps the default my.cnf files should have this information uncommented to match?

Checking the file creation priviliges as part of installation would be very helpful as well.  Perhaps "configure" could check whether the default mysql user can create a file in the important locations?  Or perhaps the mysql_install_db script could be run as the mysql user, so that it can give a heads up that the system has permission problems?

Thanks!
[5 Dec 2003 23:57] Dean Ellis
The necessity of correctly setting ownership/permissions is well-documented in the installation chapters of the manual, so this truly is not a bug.

Thank you
[6 Dec 2003 0:49] [ name withheld ]
OK, if you feel this could be a feature request, I'd like it if you could make it one.  I disagree that this is well treated by the installation manual, however.  I did perform the steps listed there---the problem is that if a higher directory does not allow permisssions, the chmod's in the manual do not solve the problem.  But this problem can probably be considered a special case of #2029.  

I'll mention that I gave up on putting things in the default of "/usr/local" and went with the "configure --prefix /usr/local/mysql" as the manual recommends.  Things went much better when I did this.

Thanks!
[4 Apr 2005 3:38] [ name withheld ]
if this isn't a bug .... it sure is a recurring problem. Argue all you want but this is an Install package from MySQL.com's download page and when this problem comes up on a regular basis... well I'd call that a bug in the install package. 

I still haven't figured out how to set the premission, and i've spent days going through your manual with no success.

thank you
[1 Aug 2005 16:51] Jason Knight-Martin
Hi All;

This is no-ones fault really. It is not a "bug", but an inconvience.

In theory, if you are using a nix based system, you should know about permissions. I knew, I have had similar problems. But I still spent 20 minutes reading and checking the log file before the obvious hit me.

There would be no need to change MYSQL code, or MYSQL Error messages, instead, a note could be added to the manual addressing said issue.

It has, quite apparently become an issue...if not a bug.

It is just a matter of conveince to MYSQL users, to mention a little more on permissions in the manual.

Just my thoughts, but really MYSQL isn't at fault, it's we who made the mistake.

Jason Knight-Martin
[4 Jan 2006 3:06] [ name withheld ]
It would also be nice if at the end of all of this someone would have posted what the resolution to the problem is. I don't consider it a bug but it's obviously a pretty bad issue considering all the comments here and on the web concerning this issue. It's also odd that in previous biulds mysql created these items and gave them proper permission and now all of a sudden it does not anymore.
[12 Jan 2006 5:53] Simon Rodan
I have to agree with ths comment that this is a problem if not structly a bug.
mysql_install_db created the /usr/local/mysql/var directory and the scrips surely shold set the ownership and permission so that mysql starts without having to set both ownership and permissions.  I took my a good 30 minutes to track this down (and quite frankly I have better thigs to do with my time). It may be a small thing but small things can be the most irritating... 

To reporduce this:
- build from course as per the manual
- run mysql_install_db
Then:
chown -R mysql /usr/local/mysql/var
chmod -R 755l /usr/local/mysql/var

now mysqld will run...
[12 Jan 2006 5:54] Simon Rodan
Sorry for the typos and the prior post -- its late, and I'm tired..
[12 Jan 2006 6:25] Simon Rodan
Mea culpa. As a last resort I read the manual rather than my old notes and the installation now works fine. My apologies. To paraphrase Salvor Hardin: "the manual is the last resort of the incompetent..."