I recently moved my MySQL database data directory from the default location /var/lib/mysql
onto a new harddrive located in /media/..UID../mysql
, following the steps you can find in several posts.
- stop the MySQL
- Copy the old folder to the new location
- Change the
datadir
in the[mysqld]
of/etc/mysql/my.cnf
- Change the two entries in the AppArmor configuration
- Adjust the user rights from the data dir
- Restart AppArmor
- Restart MySql
After those steps I tried to create a new database and it worked, it appears also in the new folder. Then I created a new InnoDB table and it also worked and it places the *frm
file into the /mysql/new
folder. But then I wanted to create a MyISAM table into this database, I received the error
#1 - Can't create/write to file '/media/..UID../mysql/new/tableName.MYI' (Errcode: 13)
I tried already to set all permission to 777, as I thought it is a permission problem (but as InnoDB can write into that folder, I cannot see why MyISAM cannot!?). For me it looks like that the MyISAM engine needs somewhere else special permission in order to write it's files, but I do not know where.
First I thought that it is a mounting problem of that new harddrive, but then again – the InnoDB can create database folders and also create files inside these folders.
So, any help is appreciated, if someone had a similar issue after moving a MyISAM table and could give some hints where to look or what else to try.
Thanks a lot already in advance!
Best Answer
I had a similar problem.
Here's what worked on Ubuntu 12.04
To move datafiles from
/var/lib/mysql
to/newdir_path/newdir
change
datadir
to/newdir_path/newdir
instead of:
enter:
Now run: