Migrating MySQL database files under Linux system

Source: Internet
Author: User

Linux (here is CentOS), after MySQL installation, the database data is stored by default in the/var/lib/mysql directory, if the directory is loaded with little disk space, not enough, you need to migrate to other directory locations.
Method One:
Refer to the method under Windows, move the/var/lib/mysql to the desired directory, modify the/etc/my.cnf file, and specify the data directory. This is a lot of tutorials online, you can go to search.
Method Two:
Use the soft Connect method under Linux, as follows: (Take the migration to the/home/mysql/directory as an example)

Stop MySQL First:
  /etc/init.d/mysqld stop
Moving data:
  Mv/var/lib/mysql/home/mysql
To create a soft connection:
  Ln-s/home/mysql/var/lib/mysql
Start MySQL:
/etc/init.d/mysqld start

This assumes that MySQL can start normally when the MySQL database file is not moved, the above steps do not involve file attributes and group modifications, and the methods for modifying attributes and genera are as follows:

Chown Mysql:mysql/home/mysql-r (The above steps do not require this action)

Note: If there is a problem with the above configuration, add the Mysql:mysql attribute and group to the top-level directory where the new database file resides.

For example: After moving to the/root/or/root/data/directory, the startup fails, and modifying the/root group can start:

[Email protected] lib]# chown mysql:mysql/root/

If you move to the/root/directory to start, and you move to the/root/data directory under Startup failure, modifying the properties of the/root/data can:

[email protected] lib]# chown mysql:mysql/root/data

After the above operation, the MySQL database file location is moved, MySQL can start normally.

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.