Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanted to have my mysql config in svn to be versionised so i did thefollowing:

ubuntu@ip-10-226-50-211:~/mysql-config$ ls -la /etc/mysql/conf.d/
total 12
drwxr-xr-x 2 root root 4096 2011-01-27 11:45 .
drwxr-xr-x 3 root root 4096 2011-01-27 11:42 ..
lrwxrwxrwx 1 root root   37 2011-01-27 11:45 flimmit.cnf -> /home/ubuntu/mysql-config/flimmit.cnf

A link in conf.d folder points to my local config. The global mysql config is untouched, i installed a fresh release of ubuntu lucid LTS.

flimmit.cnf looks like this:

bind-address           =
max_connections        = 600
server-id               = 1
log_bin                 = /var/log/mysql/mysql-bin.log
binlog_do_db            = flimmit_shop_14
binlog_do_db            = flimmit_search_14
datadir         = /media/mysql-ebs/datadir

The chmod of this config is 644

So i stopped mysql, activated the config, moved all contents of /var/lib/mysql to the new location /media/mysql-ebs/datadir

same for the log, but there wasnt any yet.

i chowned the whole /media/mysql-ebs folder to mysql.mysql (recursively)

the contents of the data dir are

debian-5.1.flag  ibdata1  ib_logfile0  ib_logfile1  mysql  mysql_upgrade_info

problem is now that the sudo start mysql seems to hang

my mysql error.log states:

110127 11:57:58 [ERROR] Fatal error: Can't open and lock privilege tables: Table '' doesn't exist

Some place i read something about not copying ib_arch_log_0000000000, ib_logfile0.

So what files to copy? What not? And Why?


I tried it also with moving only the mysql folder (mysql database) and nothing else. same thing. I also read something about modifying the init script, but theres no such thing in my init script and i would really find it stupid if the datadir would have to be defined in the init script and the config file.


after a while i saw that apparmor was running, so i adjusted the rules accordingly:

  #/var/lib/mysql/ r,
  #/var/lib/mysql/** rwk,
  /media/mysql-ebs/datadir/ r,
  /media/mysql-ebs/datadir/** rwk,

for now i discarded the changement of the log dir and focused only on the data dir. but somehow this didnt change anything. of course i restarted apparmor.


i confirmed the problem IS appaormor. after running /etc/init.d/apparmor teardown everything worked fine. But what is wrong with the config? I will post it as a whole:

# vim:syntax=apparmor
# Last Modified: Tue Jun 19 17:37:30 2007
#include <tunables/global>

/usr/sbin/mysqld {
  #include <abstractions/base>
  #include <abstractions/nameservice>
  #include <abstractions/user-tmp>
  #include <abstractions/mysql>
  #include <abstractions/winbind>

  capability dac_override,
  capability sys_resource,
  capability setgid,
  capability setuid,

  network tcp,

  /etc/hosts.allow r,
  /etc/hosts.deny r,

  /etc/mysql/*.pem r,
  /etc/mysql/conf.d/ r,
  /etc/mysql/conf.d/* r,
  /etc/mysql/my.cnf r,
  /usr/sbin/mysqld mr,
  /usr/share/mysql/** r,
  /var/log/mysql.log rw,
  /var/log/mysql.err rw,
  #/var/lib/mysql/ r,
  #/var/lib/mysql/** rwk,
  /media/mysql-ebs/datadir/ r,
  /media/mysql-ebs/datadir/** rwk,

  /var/log/mysql/ r,
  /var/log/mysql/* rw,
  /var/run/mysqld/ w,
  /var/run/mysqld/mysqld.sock w,

  /sys/devices/system/cpu/ r,
share|improve this question

are you sure that mysql user has access to /home/ubuntu/ directory?

share|improve this answer
yes, i became mysql using sudo -u mysql bash -l and was able to cat the content of the config file – The Shurrican Jan 27 '11 at 13:34

Try change permission to datadir:

chown -R mysql:mysql /media/mysql-ebs/datadir/mysql
chown mysql:mysql /media/mysql-ebs/datadir/
chown mysql:mysql /media/mysql-ebs/
share|improve this answer
i forgot to mention that i chowned recursively – The Shurrican Jan 27 '11 at 13:30
up vote 1 down vote accepted

i finally forgot to add the external config file to apparmor profile. now everything works

share|improve this answer
How does one do this? – richardkmiller Nov 16 '11 at 0:28
app armor got installed as default with the ubuntu server upgrade to version 10.04 which i was not aware of. – The Shurrican Nov 16 '11 at 17:30

Your Answer


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.