We can change mysql data directory by doing the following steps.

+ Stop the mysql service.

#/etc/init.d/mysql stop

+ Create a directory in /home directory (Normally /home contains large disk space)

# mkdir /home/var_mysql

+ Move the mysql data directory to new location i.e., /home/var_mysql

# mv /var/lib/mysql /home/var_mysql

+ Change the permission of this directory to “mysql”.

# chown -R mysql:mysql /home/var_mysql/mysql

+ Create a symlink to /var/lib/mysql.

# ln -s /home/var_mysql/mysql /var/lib/mysql

+ Start mysql service.

# /etc/init.d/mysql start

+ Check the mysql data directory by using ps command. This will show the mysql data directory.

# ps aux | grep mysql


Leave a Reply