Modifying the MARIADB storage path

Source: Internet
Author: User

Most actions based on this article: http://lddyw.blog.51cto.com/4151746/1684364

Find a long-time information, are intended to install the source, finally changed successfully.

Environment: CentOS6.6 64-bit virtual machine, MariaDB 10.0.20

Database Installation method: RPM Package Local Installation

Note: The owner of the file involved in MARIADB is automatically changed to MySQL when the RPM package is installed.

Document Purpose: Change the default storage data directory of the database to/data/mysql_data/mysql

First, make sure that the MARIADB database works correctly.

12 service mysql start service mysql status

OK to close service after normal

1 service mysql stop

Create a directory where you want to change the data stored, such as: I've split the area alone./data Store MARIADB Data

12 mkdir /data/mysql_data chown -R mysql:mysql /data/mysql_data

Copy the default data storage folder to/data/mysql_data

1 cp -a /var/lib/mysql    /data/mysql_data

Modify/ETC/MY.CNF.D/SERVER.CNF

1 vim /etc/my.cnf.d/server.cnf

Under the [Mysqld] tab, add the following:

1234567891011 #--------------------------add by  Root----------------------------- # add for moving  Data to /data/mysql_data # Datadir=/data/mysql_data/mysql socket=/var/lib/mysql/mysql.sock #default-character-set=utf8 character_set_server=utf8 Code class= "CPP Plain" >slow_query_log=on slow_query_log_file=/data/mysql_data/slow _query_log. log long_query_time=2 #--------------------------end-------------------------------------

Exit Save ESC

1 :wq

Configure MARIADB Slow Query

12 touch /data/mysql_data/slow_query_log.logchown mysql:mysql /data/mysql_data/slow_query_log.log

Restart database

1 service mysql start

Done!

At this point, the newly created database and table will be stored under the/data/mysql_data/mysql/path.

This resolves the following:

1, the configuration file my.cnf exists, but the change is not my.cnf, but/etc/my.cnf.d/server.cnf;

2, and did not change the path configuration of Mysql.sock;

3, did not modify the contents of the/etc/init.d/mysql;

4, did not modify the contents of the Mysql_safe;

5, increased the database slow query configuration.

One of the details, forgot to turn off selinux, resulting in the replacement of the path, unable to start MySQL.

Modifying the MARIADB storage path

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.