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