Changing MySQL data directory in CentOS is a very 6 simple steps.
You need root access to your CentOS. Login and do followings
- stop the mysql
# # /etc/init.d/mysqld stop #
- copy all the current data to your destination directory (you need to decide where you want to move your mysql data)
# # cp /var/lib/mysql/ /mysqldata/mysql/ -R #
- give your new directory proper rights
# # chown mysql.mysql /mysqldata/mysql/ -R #
- Add new directory path to you my.cnf
# nano /etc/my.cnf # # [mysqld] #datadir=/var/lib/mysql datadir=/mysqldata/mysql/ socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
see the highlighted lines we changed the “datadir” to our new Path.
- Optional you should remove or atleast rename the actual MySQL directory. Just to make sure that you are using new data directory
# # mv /var/lib/mysql /var/lib/mysql_ORIGNAL #
- Start Mysql
# # /etc/init.d/mysqld start #
No Comments Yet