Move data mysql mariadb sang thư mục khác

service mariadb stop

rsync -av /var/lib/mysql /home/innocom

mv /var/lib/mysql /var/lib/mysql.bak

vi /etc/my.cnf

[mysqld]
. . .
datadir=/home/innocom/mysql
socket=/home/innocom/mysql/mysql.sock
. . .

After updating the existing lines, we’ll need to add configuration for the mysql client. Insert the following settings at the bottom of the file so won’t split up directives in the [mysqld] block and above the include line:

[client]
port=3306
socket=/home/innocom/mysql/mysql.sock

!includedir /etc/my.cnf.d

------

chcon -Rt mysqld_db_t /home/innocom/mysql

chcon -Ru system_u /home/innocom/mysql
chown -R mysql:mysql /home/innocom/mysql

systemctl start mariadb

(2) Comments

  1. kiểm tra phpinfo xem mysql đã gọi sang folder mới chưa, nếu chưa sửa trong file php.ini
    mysqli.default_socket = /home/innocom/mysql/mysql.sock

Leave a Reply

You must be logged in to post a comment.