Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

service mysqld start gives me:

Starting mysqld (via systemctl):  Job failed. See system logs and 'systemctl status' for details.
                                                           [FAILED]

Error log says:

110913 05:50:44 mysqld_safe Starting mysqld daemon with databases from /home/mysql/prod
110913  5:50:44 [Warning] Can't create test file /home/mysql/prod/myhostname.lower-test
110913  5:50:44 [Warning] Can't create test file /home/mysql/prod/myhostname.lower-test
110913  5:50:44 [Note] Plugin 'FEDERATED' is disabled.
110913  5:50:44 InnoDB: The InnoDB memory heap is disabled
110913  5:50:44 InnoDB: Mutexes and rw_locks use GCC atomic builtins
110913  5:50:44 InnoDB: Compressed tables use zlib 1.2.5
110913  5:50:44 InnoDB: Using Linux native AIO
110913  5:50:44 InnoDB: Initializing buffer pool, size = 16.0M
110913  5:50:44 InnoDB: Completed initialization of buffer pool
110913  5:50:44  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 /home/mysql/prod/ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
110913 05:50:44 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

Oh, error 13, so it's a permissions problem, right?

chown -R mysql:mysql /home/mysql/prod

Still won't start... let's try this:

/usr/libexec/mysqld --console --log-warnings --basedir=/usr --datadir=/home/mysql/prod --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock

Ok, so that starts fine (I can login using mysql -u root -p), but I don't even know what that's doing, it certainly isn't managed by systemctl.. let's make sure mysql is a user:

# grep 'mysql' /etc/passwd
mysql:stuff:stuff:MySQL Server:/var/lib/mysql:/bin/bash

My my.cnf, somewhat abbreviated (I've tried quite a few variations of the below):

[client]
#password       = your_password
port            = 3306
socket         = /var/lib/mysql/mysql.sock

[mysqld]
user            = mysql
port            = 3306
basedir         = /usr
log_warnings    = 1
datadir         = /home/mysql/prod
socket          = /var/lib/mysql/mysql.sock
log-error       = /var/log/mysql.log


innodb_data_home_dir = /home/mysql/prod
innodb_data_file_path = ibdata1:10M:autoextend
#innodb_doublewrite = on
#innodb_log_group_home_dir = /home/mysql/prod

I'm kindof at a loss here.. can anyone drop me a line?

# ls -lah / | grep 'home'
drwxr-xr-x.   6 root root 4.0K Aug 15 12:20 home
# ls -lah /home | grep 'mysql'
drwxr-xr-x.  6 mysql    mysql    4.0K Sep  8 06:14 mysql
# ls -lah /home/mysql/prod
drwxr-x---.  2 mysql mysql 4.0K Sep 14  2009 bugs
-rw-r--r--.  1 mysql mysql  18M Sep 13 06:17 ibdata1
-rw-r--r--.  1 mysql mysql 5.0M Sep 13 06:17 ib_logfile0
-rw-r--r--.  1 mysql mysql 5.0M Sep 13 05:23 ib_logfile1

(removed some stuff above for privacy)

share|improve this question
    
To clarify, you're running service mysqld start as a normal user, not root? –  sreimer Sep 13 '11 at 15:28
    
I was running everything from the shell as root.. the below answer fixed my problem. –  Stephen J. Fuhry Sep 16 '11 at 16:26

1 Answer 1

up vote 4 down vote accepted

If you're using SELinux (Fedora, SUSE, some Ubuntu), it is probably the problem. You need to change your security context for mySQL with something like:

chcon -Rv --type=mysqld_db_t /my/new/data/dir

or if you're using AppArmor (Ubuntu), you'll need to update your

/etc/apparmor.d/usr.sbin.mysql
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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