Modify the MySQL Data directory

Source: Internet
Author: User

1. Turn off MySQL:

#service mysqld Stop

2. Transfer data:

#cd/var/lib
#ls
#cp-A mysql/mnt/sdb/mysql/

3, modify the configuration file, a bit three:

#vi/etc/my.cnf
Add under [client]
Socket=/mnt/sdb/mysql/mysql.sock
Comment out the previous code
#datadir =/var/lib/mysql
#socket =/var/lib/mysql/mysql.sock
Modified to:
Datadir=/mnt/sdb/mysql
Socket=/mnt/sdb/mysql/mysql.sock
#vi/etc/init.d/mysqld "Modify DataDir's Directory"
Comment out the previous code
#get_mysql_option mysqld datadir "/var/lib/mysql"
Modified to:
Get_mysql_option mysqld datadir "/mnt/sdb/mysql"

#vi/usr/bin/mysqld_safe "Modify DataDir's Directory"
Comment out the previous code
#DATADIR =/var/lib/mysql
Modified to:

Datadir=/mnt/sdb/mysql
4. Need to establish a mysql.sock link:
#ln-S/mnt/sdb/mysql/mysql.sock/var/lib/mysql/mysql.sock
Now that all the changes are complete, start MySQL below
5. #service mysqld Start


This article is from the "Chen Shifei" blog, make sure to keep this source http://chenshifei.blog.51cto.com/11883413/1883938

Modify the MySQL Data directory

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.