Mysql Data store folder change

I have installed Percona mysql in my ubuntu server successfully. I need to move percona data location from /var/lib/mysql to /mysql-data directory.Because /mysql-data directory is encrypted volume.How to move percona data folder into this location

  • stop mysql server
  • change the /mysql-data directory owner and group to the same as /var/lib/mysql, and to the same chmod
  • copy the data files and directories to the new directory (including the /var/lib/mysql/mysql directory)
  • make sure the rights on destination directory/files are correct again
  • add
    datadir = /mysql-data
    to your mysql config
  • restart the server

Its works

While I’m having the same permission to the new dir still couldn’t start the mysql.

[root@ip-10-99-10-103 mysql]# ls -ltr /data/
total 20
drwx------. 2 root root 16384 Feb 14 15:14 lost+found
drwxr-xr-x. 5 mysql mysql 4096 Feb 14 17:48 mysql

[root@ip-10-99-10-103 mysql]# ls -ltr /var/lib/ |grep mysql
drwxr-x—. 2 mysql mysql 6 Dec 18 17:35 mysql-keyring
drwxr-x—. 2 mysql mysql 6 Feb 14 17:48 mysql-files
drwxr-x–x. 5 mysql mysql 4096 Feb 15 12:36 mysql

Check if you have SElinux enabled.