Sunday, July 12, 2009

Migrating the default Database location of MySQL

There are some simple steps if you need to change the default location of the MySQL Database.

1. Create new data directory data for new data directory.

mkdir data
chown -R mysql:mysql data

2、Stop MySQL process

# service mysqld stop
Stopping MySQL: [ OK ]

ps -efgrep mysql to check

3、Copy /var/lib/mysql to /home/data

cp -rfp /var/lib/mysql/* /home/data

4、Backup old /etc/my.cnf to /etc/my.conf.bak

5、Edit /etc/my.cnf

find line like bellow
#datadir=/var/lib/mysql
datadir=/data

6、Backup script /etc/init.d/mysqld to /etc/init.d/mysqld.bak and edit

# vi /etc/init.d/mysqld

#get_mysql_option mysqld datadir "/var/lib/mysql"
get_mysql_option mysqld datadir "/data"

7. Relink : ln -s /home/data /var/lib/mysql

8. Start mysqld servicce

# service mysqld start
Starting MySQL: [ OK ]

Cheerz.
@$H

No comments:

Post a Comment

The Azure Synapse Resource Provider Error

  If you are get the error " The Azure Synapse resource provider (Microsoft.Synapse) needs to be registered with the selected subscript...