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
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