Changing the MARIADB data storage path under lamp

Source: Internet
Author: User

By default, mariadb is stored as/var/lib/mysql/, and is now changed to/media/data/mysql for some reason.

1, first stop the mariadb and httpd daemon:

# Systemctl Stop Mariadb.service

# Systemctl Stop Httpd.service


2. Copy the/var/lib/mysql/to the/media/data/:

# cp-avp/var/lib/mysql//media/data/

3, modify the MARIADB configuration file:

Check the configuration file for mariadb:

# RPM-QC Mariadb-server

/etc/logrotate.d/mariadb

/etc/my.cnf.d/server.cnf

/var/log/mariadb/mariadb.log

It can be concluded that the configuration file to be modified is/ETC/MY.CNF.D/SERVER.CNF and modified:

Backup first, just in case:

# cp-p/etc/my.cnf.d/server.cnf/etc/my.cnf.d/server.cnf.backup

Modify the MARIADB server, comment out the original datadir and socket, and add again:

# VIM/ETC/MY.CNF.D/SERVER.CNF

[Mysqld]

#datadir =/var/lib/mysql

Datadir=/media/data/mysql

#socket =/var/lib/mysql/mysql.sock

Socket=/media/data/mysql/mysql.sock

Modify the configuration file for the MARIADB client (if you do not modify this, you will be prompted to not find the socket file when using MySQL to connect to the server):

# cp-p/etc/my.cnf.d/client.cnf/etc/my.cnf.d/client.cnf.backup

# VIM/ETC/MY.CNF.D/CLIENT.CNF

[Client]

Socket=/media/data/mysql/mysql.sock


4, modify the PHP connection mariadb socket Location:

# Vim/etc/php.ini

Mysql.default_socket =/media/data/mysql/mysql.sock

#此项一般为空, now requires a phone designation, or PHP cannot communicate with MARIADB

5. Start mariadb and httpd services:

# Systemctl Start Mariadb.service

# Systemctl Start Httpd.service

At this point, the modification is complete.


This article is from the "Silver Kay Blog" blog, make sure to keep this source http://yinkai.blog.51cto.com/3813923/1728053

Changing the MARIADB data storage path under lamp

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.