Change the default MySQL data directory with SELinux disabled

Linux platform: CentOS 6.5 x86_64 with mysql 5.1


1. service mysqld stop


2. mkdir -p /new/mysql (or anywhere you want to)


3. chown -R mysql.mysql /new/mysql


4. mv /var/lib/mysql/* /new/mysql/


5. vi /etc/my.cnf

datadir=/new/mysql

socket=/new/mysql/mysql.sock

[client]
socket = /new/mysql/mysql.sock


6. service mysqld start


7. mysql -uroot

mysql> show databases;


8. you may have to change database related software (like zabbix using mysql) configuration file to the correct socket (/new/mysql/mysql.sock)

你可能感兴趣的:(mysql)