Ubuntu :: Move datadir directory in MySQL

37 sec read

:: What’s MySQL
MySQL is open-source relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases.

:: How to move datadir MySQL directory in Linux Ubuntu
+ Stop mysqld

/etc/init.d/mysql stop

+ Move or copy mysql data to new location (/home)

mv /var/lib/mysql /home


rsync -aAXv /var/lib/mysql /home

+ Change permission in new location

chown -R mysql.mysql /home/mysql

+ Setting my.cnf

vi /etc/mysql/my.cnf

commented or change in this:

# datadir = /var/lib/mysql

add or change to this line:

datadir = /home/mysql

+ Add new location path in apparmor.d

vi /etc/apparmor.d/usr.sbin.mysqld

commented or change in these line:

#/var/lib/mysql/ r,
#/var/lib/mysql/** rwk,

add or changed with these:

/home/mysql/ r,
/home/mysql/** rwk,

+ Reload apparmord

/etc/init.d/apparmor reload

+ Starting mysqld using new location datadir

/etc/init.d/mysql start

:: link
+ Google
+ askubuntu

Reset root password on CentOS 7

Edit boot menu on-the-go 0. reboot the CentOS 7 and press ESC when GRUB menu show up on the screen and press “e”1. find...
18 sec read

Leave a Reply

Your email address will not be published. Required fields are marked *