Modify the path of the mariadb database file under CentOS7

Source: Internet
Author: User
The default data document storage directory of mariadb is/var/lib/mysql. to change the default directory to/data, perform the following operations: 1. create the/data Directory mkdir/datachmod777/data (to assign at least the read and write permissions to this directory). 2. stop the mariadb service: the default data document storage directory of mariadb is/var/lib/mysql. to change the default directory to/data, perform the following operations:

1. create/data Directory

Mkdir/data

Chmod 777/data (at least read and write permissions must be attached to this directory)


2. stop the mariadb service:
Systemctl stop mariadb. service

3. copy the entire/var/lib/mysql directory to/data
Cp-r/var/lib/mysql/*/data/
In this way, the MySQL data file is copied to/data.

4. edit the configuration document/etc/my. cnf of mariadb.

Add the following under [client:

Comment out the original socket =/var/lib/mysql. sock, add # to the front, and add socket =/data/mysql. sock (in case of any problem, change it back ).

Add the following under [mysqld:

Comment out the original socket =/var/lib/mysql. sock, add # to the front, and add socket =/data/mysql. sock (in case of any problem, change it back ).

Datadir =/datal (this line does not exist. you need to add it yourself)

Save and exit.
 
5. chown-R mysql: mysql/data/mysql


6. restart the mariadb service.
Systemctl start mariadb. service.

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.