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

I'm currently running Ubuntu 13.04 and MySQL 5.5. I have been using InnoDB, and the default location for installation. The problem is that my main OS partition is fairly small (36GB), and I need to move my database to my 2TB drive.

I'm trying to change MySQL datadir from:




but I've been running into all kinds of problems. MySQL refuses to start, and generally tells me there are problems with permissions. This doesn't make any sense to me, though. Here is what I have tried doing:

I copied the files:

cp -R /var/lib/mysql /path/to/new/directory

I edited /etc/mysql/my.cnf :


Updated the permissions:

chown -R mysql:mysql /path/to/new/directory

Updated Apparmor:

/path/to/new/directory/ r,
/path/to/new/directory/** rwk,

I make sure to reset Apparmor:

service apparmor restart

But it still gives me errors. I am not sure what else I need to do. Does anyone have a definitive guide to making this work under Ubuntu 13.04, MySQL 5.5, and InnoDB?

share|improve this question
First of all, this is not a Ubuntu issue. Second, in general you cannot just copy a couple of folders and demand that the software continues to function as nothing has changed. Third, start by reading the MySQL reference manual. The chapter about installation is exaustive. Fourth, why move the program? Just move the datadir... and anyway standard mysql database size limit is 2GB unless set otherwise at initialization. – hmayag May 14 '13 at 20:47
I thought this might be an Ubuntu issue because of Apparmor. I didn't just copy a few folders. I never said I was moving the whole program. – Jester87 May 14 '13 at 21:01
Yes, I read your question more carefully. Sorry about that. Try initializing a new data space from the command line. I don't remember the exact mysql script that does that. Edit: found it. – hmayag May 14 '13 at 21:37
I tried running mysql_install_db but it didn't seem to do anything. I keep getting permission errors. – Jester87 May 14 '13 at 23:40
Well, I got it to work if i change the user to root in my.cnf. This is not ideal, though. Any suggestions on figuring out where the permission problems are happening? – Jester87 May 14 '13 at 23:50
up vote 0 down vote accepted

I faced the exact same problem, but I've found a better alternative that did work for me, since changing the user to root in the my.cnf file didn't work for me.

  1. First head to the MySQL data directory and move all ibdata files and all ib_logfile files to a temp folder (should look similar to mv /path_to_mysql_data_directory/ib* /path_to_temp_folder/).
  2. Run sudo service mysqld start and it should start.
  3. Run sudo service mysqld stop and it should stop.
  4. Take the file you moved to the temp folder and put them back in the MySQL data directory (should look similar to mv /path_to_temp_folder/ib* /path_to_mysql_data_directory/).
  5. Run sudo service mysqld start again and everything should start.

This solution did work for me, but I haven't tested it elsewhere.

share|improve this answer

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.