Wednesday, July 22, 2009

Change mysql data directory

The default location is /var/lib/mysql

You can change mysql data directory by adding the following entries in /etc/my.cnf file

datadir=newlocation/path

save the file, move the necessary database files from /var/lib/mysql to the new location and restart mysql.

To check if the new location is added correctly, login to mysql as root and create a test database and check the new location if the new database files are added or not.

If mysql doesnt start after restarting then check the logs for an error

# tail -f /var/log/mysqld.log

If there are no specific errors mentioned check if selinux is enabled or not. If its enabled then you may disable it and try starting mysql.

commands to check if selinux is enabled

#getenforce

the result will be like enabled, permissive or targeted You can disable it by editing the configuration file /etc/selinux/config (RHEL/centos)

No comments:

Post a Comment