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
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
Configure MARIADB Slow Query
12 |
touch /data/mysql_data/slow_query_log. log chown mysql:mysql /data/mysql_data/slow_query_log. log |
Restart database
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