Migrating MySQL's Data directory

Source: Internet
Author: User
Tags mysql client

The default data file storage directory for MySQL is/var/lib/mysql. The following steps are required if you want to move the directory to/home/data:

1. Create a directory under Home mkdir-p/home/data/mysql

2. Stop MYSQLD Service

/etc/init.d/mysqld stop

3. Migrate the contents of the/var/lib/mysql directory below to/home/data/mysql

4. Modifying the MY.CNF configuration file

If there is no MY.CNF configuration file under the/etc/directory, locate the *.cnf file under/usr/share/mysql/, and copy one of them to/etc/and rename it to MY.CNF). The command is as follows:

[Email protected] mysql]# CP/USR/SHARE/MYSQL/MY-MEDIUM.CNF/ETC/MY.CNF

5. Edit the MySQL configuration file/etc/my.cnf

[Mysqld]
Datadir=/home/data/mysql
Socket=/home/data/mysql/mysql.sock
[Client]
Socket=/database/mysql/mysql.sock
In general, users often forget to add [client] segments to modify the client because the MySQL client program will still connect to/var/lib/mysql/ Mysql.sock This socket above, at this time although the database has started normally, using MySQL to connect to the database is still reported to find no/var/lib/mysql/mysql.sock error

6. Modify MySQL startup script/etc/init.d/mysql

Finally, you need to modify the MySQL startup script/etc/init.d/mysql, put it get_mysql_option mysqld datadir "/var/lib/mysql" line, the path in the quotation marks is changed to your current actual storage path: home/ Data/mysql.

7. Restart MySQL Service

/etc/init.d/mysql Rstart



This article from the "Technology is tossing" blog, please be sure to keep this source http://jamswu.blog.51cto.com/6391890/1415160

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.