Change MYSQL data directory

Sometimes you need change mysql data directory for the reason expand hard disk driver or rearrange your directory structure. This tutorial will show you the way to change it in Ubuntu.

For example, change mysql data directory from /var/lib/mysql to /var/data/mysql

Looking for:

Change to :

And open file:

Looking for:

Change to:

Reload AppArmor profile:

Finally, restart MYSQL:

It’s done.