mysql也是相似的配置。MariaDB
默认的数据的存储目录为/var/lib/mysql
,准备改成/data/mysql
。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表情是没法正确存储的。sql
# 登陆 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)