Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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

First of all let me say that this is a question following my attempt to do the solution on this post Can I share MySql database files with Windows on dual boot? . I was hit by an error and need help solving it. I posted this as an "answer" there and was advised to open a new question:

So, here is my problem. I'm running Kubuntu 12.04, and Windows 7 Ultimate. My mysqldata folder right now rest on a second hardrive, which is my Data drive shared between both installs This is the line for it on my fstab:

UUID=9EEAD9BAEAD98F41                      /media/Data  ntfs-3g  defaults,windows_names,locale=en_US.utf8  0 0

I tried adding uid=mysql,gid=mysql to the options line. A ls -la /media/Data shows that it indeed was mounted for the correct users and also the permissions were 777. Same goes for the /media/Data/Sistemas/mysqldata folder. The first errors I'm getting, in all of the cases are:

/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
130114  2:09:08 [Warning] Can't create test file /media/Data/Sistemas/mysqldata/verditius.lower-test
130114  2:09:08 [Warning] Can't create test file /media/Data/Sistemas/mysqldata/verditius.lower-test
/usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
130114  2:09:08 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
130114  2:09: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.

So, what can I do to solve this?

Here is the bit on mysql.cnf which I think is important:

user            = mysql
pid-file        = /var/run/mysqld/
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /media/Data/Sistemas/mysqldata
tmpdir          = /tmp
lc-messages-dir     = /usr/share/mysql
share|improve this question

Ok, I managed to make it work after checking another thread on the ubuntu forums. The problem is that you need to allow the mysql service rw access to the new location on apparmor. This is the thread

But you don't need to do all that, just add the new location to the /etc/apparmor.d/usr.sbin.mysqld and change your datadir entry on my.cnf

/path/to/new/datadir/ r,
/path/to/new/datadir/** rwk,
share|improve this answer
Exactly, this is a common error. However, consider the use of /etc/apparmor.d/local/usr.sbin.mysqld (create or edit) instead of editing a global file. This may break upgrades later done by your package management if you do edit these. – gertvdijk Jan 15 '13 at 15:44

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.