How do I give mysqld write access to a directory?

I am running OSX right now and trying to run a mysqld process and seeing the following error:

 $ /usr/local/mysql/bin/mysqld --user=root
111026 11:05:08 [Warning] Can't create test file /usr/local/mysql-5.5.15-osx10.6-x86_64/data/XXX.lower-test
111026 11:05:08 [Warning] Can't create test file /usr/local/mysql-5.5.15-osx10.6-x86_64/data/XXX.lower-test
111026 11:05:08 [Warning] One can only use the --user switch if running as root

111026 11:05:08 [Note] Plugin 'FEDERATED' is disabled.
/usr/local/mysql/bin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
111026 11:05:08 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
111026 11:05:08 InnoDB: The InnoDB memory heap is disabled
111026 11:05:08 InnoDB: Mutexes and rw_locks use GCC atomic builtins
111026 11:05:08 InnoDB: Compressed tables use zlib 1.2.3
111026 11:05:08 InnoDB: Initializing buffer pool, size = 128.0M
111026 11:05:08 InnoDB: Completed initialization of buffer pool
111026 11:05:08  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.

I understand the problem is since I am not using sudo, my current user account does not have write access to

/usr/local/mysql-5.5.15-osx10.6-x86_64/data/

I am trying accomplish two different things

  1. Give the mysqld process write access to that directory without using chmod 700 or whatever. I am trying to use chown and it is not working

  2. Create a script so the mysqld process starts at boot-up

Can anyone help me?


Depending on the uid mysqld is using, chmod 700 on the data directory might not help. You may do the following:

  • chmod 777 /usr/local/mysql-5.5.15-osx10.6-x86_64/data/
  • Startup mysqld again
  • ls -l /usr/local/mysql-5.5.15-osx10.6-x86_64/data/ to identify the owner of the created files
  • chown OWNER /usr/local/mysql-5.5.15-osx10.6-x86_64/data
  • chmod 700 /usr/local/mysql-5.5.15-osx10.6-x86_64/data/