redhalt更改mysql存储路径_CentOS修改Mariadb数据库文件存储路径

修改Mariadb数据库文件存储路径

mysql也是类似的配置。

MariaDB默认的数据的存储目录为/var/lib/mysql,准备改为/data/mysql。

停止服务

systemctl stop mariadb

数据迁移

mv /var/lib/mysql /data/mysql

修改配置

vim /etc/my.cnf

# 在[client-server]中添加

socket=/data/mysql/mysql.sock

# 在[mysqld]中添加,末尾必须是/

datadir=/data/mysql/

完整配置

#

# This group is read both both by the client and the server

# use it for options that affect everything

#

[client-server]

socket=/data/mysql/mysql.sock

#

# include all files from the config directory

#

!includedir /etc/my.cnf.d

[mysqld]

init_connect='SET collation_connection = utf8mb4_unicode_ci'

init_connect='SET NAMES utf8mb4'

character_set_server=utf8mb4

collation-server=utf8mb4_unicode_ci

skip-character-set-client-handshake=true

datadir=/data/mysql/

注:datadir上面的五行是设置默认字符集为utf8mb4,否则emoji表情是无法正确存储的。

验证

# 登录

mysql -uroot -p

# 查询

show global variables like "%datadir%";

# 结果

MariaDB [(none)]> show global variables like "%datadir%";

+---------------+--------------+

| Variable_name | Value |

+---------------+--------------+

| datadir | /data/mysql/ |

+---------------+--------------+

1 row in set (0.00 sec)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值