tutorial on installing Mysql on CentOS 6.x-[click here]
First, let's say we need to move the MySQL data storage location to/data.
The first step:
Service Mysqld Stop
Step Two:
# # # Back up the original mysqlcp-a/var/lib/mysql/var/lib/mysql_bak### transfer mysqlcp-a/var/lib/mysql/data/
After the transfer is complete we need to modify some parameters so that MySQL can use the new address:
# # # Back up the original file configuration information cp-a/etc/my.cnf/etc/my.cnf_bak### Modify the original configuration file vi/etc/my.cnf### find DataDir and modify the value to: datadir=/data/mysql### Locate the socket and change the value to: Socket=/data/mysql/mysql.sock
To modify a second configuration file:
# # # Back up the original file information Cp-a/etc/init.d/mysqld/etc/init.d/mysqld_bak### Modify the original file information vi/etc/init.d/mysqld### find Get_mysql_option Mysqld DataDir # # # and change the value to: Get_mysql_option mysqld datadir "/data/mysql" # # # Find DataDir and change the value to: datadir= "/data/mysql"
Create a soft connection to MySQL sock after the configuration file modification is complete
# # # into the original MySQL directory cd/ver/lib/mysql### remove content rm-rf *### build Mysql.sock soft connection Ln-s/data/mysql/mysql.sock/var/lib/mysql/mys Ql.sock
Start MySQL
Service mysqld Start
If there is a problem with the permission class:
# # # Modify Permissions error file or folder as modified:/data/mysql folder permissions command Chcon-r-t Mysqld_db_t/data/mysql
If the appropriate folder permissions are modified or cannot be started
To modify the system's permission validation:
vi/etc/selinux/config### find the SELinux and change the value to: selinux=disabledesc:wq### Modify the system after saving to reboot reboot
Note: The above operations should be handled with caution in the production environment.
Data location for CentOS transfer MySQL