1

I'm trying to change the data directory of my MySQL database from the default location /var/lib/mysql to a new path which in my case is /home/dev/Desktop/iiab/db/mysql.

I have tried following the answer provided by Victor in the following post: How to change MySQL data directory? (I have also edited the alias file as per the instruction from mak in the comments on Victor's answer).

BUT, I am getting the following terminal error when trying to start MySQL again:

mysql.serviceJob for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.

When inspecting the log file using below command

tail -f /var/log/mysql/error.log

It shows the following:

2016-05-23T13:43:11.608141Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2016-05-23T13:43:11.608234Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2016-05-23T13:43:11.608252Z 0 [ERROR] Failed to initialize plugins.
2016-05-23T13:43:11.608260Z 0 [ERROR] Aborting

2016-05-23T13:43:11.608297Z 0 [Note] Binlog end
2016-05-23T13:43:11.608416Z 0 [Note] Shutting down plugin 'MyISAM'
2016-05-23T13:43:11.608469Z 0 [Note] Shutting down plugin 'CSV'
2016-05-23T13:43:11.609124Z 0 [Note] /usr/sbin/mysqld: Shutdown complete

My my.cnf file looks as follows (I omitted the initial comments ##):

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

[mysqld]
datadir=/home/dev/Desktop/iiab/db/mysql
socket=/home/dev/Desktop/iiab/db//mysql.sock

My /etc/apparmor.d/usr.sbin.mysqld file looks as follows (I only included the parts which were affected by the instructions i.e. replace var/lib/mysql with the new path).

# Allow data dir access
  /home/dev/Desktop/iiab/db/mysql/ r,
  /home/dev/Desktop/iiab/db/mysql/** rwk,

# Allow data files dir access
  /home/dev/Desktop/iiab/db-files/ r,
  /home/dev/Desktop/iiab/db-files/** rwk,

# Allow keyring dir access
  /home/dev/Desktop/iiab/db-keyring/ r,
  /home/dev/Desktop/iiab/db-keyring/** rwk,

My /etc/apparmor.d/tunables/alias file looks as follows (I omitted initial comments ##):

# Or if mysql databases are stored in /home:
alias /var/lib/mysql/ -> /home/dev/Desktop/iiab/db/mysql/,

I am able to restart and reload apparmor successfully.

I'm using Ubuntu 16.04.

Anyone know what I am doing wrong?

Community
  • 1
  • 1
Willy G
  • 1,172
  • 1
  • 12
  • 26
  • I'm guessing you might have messed up the ownership of the MySQL tables when you copied them. Check out the differences between the new ones and the originals. – Mike May 23 '16 at 15:37
  • @Mike How do I check the ownership of the tables? Googling SQL+ownernship doesn't give any valuable information. Sorry, but I'm very new to MySQL. Thanks! – Willy G May 24 '16 at 06:25
  • "ls -l" from the command line (properties from the GUI as root) will give you the owner - it should be (on my machine) mysql in the group mysql: ... "drwxrwxrwx 2 mysql mysql 4096 Sep 19 2011 portal" ... etc. You might also want to check the permissions – Mike May 24 '16 at 07:38

0 Answers0