Move MySQL database from one drive to another
Description:
Here I have describe how to move MySQL database from one drive to another when drive full or need to change hard drive.
Procedure:
1> Shutdown MySQL service using below command:
# service mysqld stop
2> Check mysql process using below command and if any process running then kill process
# ps aux |grep mysql
3> Move all contents of /var/lib/mysql [Data Dir] content to new location for this demo I create /database directory
4> Change datadir attribute in my.cnf [MySQL configuration file] as follow. Generally it is located on /etc/my.cnf or /etc/mysql/my.cnf
[mysqld]
Datadir = /database
5> Give mysql user ownership to /database directory and give 755 permission on /database directory
6> Rename /var/lib/mysql directory with new name
7> Start service using below command:
# service mysqld start
No comments:
Post a Comment