PDA

View Full Version : Steps to Change Mysql Data Path


emad
04-25-2011, 10:27 AM
Hi All,

Follow the steps to Change mysql data path.

Before changing the data path folder stop the Mysql server.

/etc/init.d/mysqld stop

Make a new directory for the data path

mkdir /opt/mysql_data

Now we need to copy the existing database in to the new location /opt/mysql_data

cp -R /var/lib/mysql /opt/mysql_data

After copying the database we need to update the new data path file in the my.cnf file.

vi /etc/my.cnf
datadir = /var/lib/mysql

Change it to

datadir = /opt/mysql_data


Now we moved the mysql data directory in to the new location and start the Mysql server to write the DB files to the new location.

/etc/init.d/mysqld start

Regards,
Emad