Data location for CentOS transfer MySQL

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.