MariaDB数据目录迁移
< 返回列表时间: 2019-10-21来源:OSCHINA
【围观】麒麟芯片遭打压成绝版,华为亿元投入又砸向了哪里?>>>
1.登陆MariaDB
# mysql MariaDB [(none)]> select @@datadir;

当前数据目录是:/var/lib/mysql/
2.创建MariaDB新的数据目录
# mkdir /data/sdv1/mydata/ # chown -R mysql:mysql /data/sdv1/mydata/ # chmod 755 /data/sdv1/mydata/
3.停止MariaDB服务
# systemctl stop mariadb.service # systemctl status mariadb.service

4.修改配置文件
# vim /etc/my.cnf # cat /etc/my.cnf [mysqld] character-set-server=utf8 #datadir=/var/lib/mysql #socket=/var/lib/mysql/mysql.sock datadir=/data/sdv1/mydata socket=/data/sdv1/mydata/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd [mysqld_safe] log-error=/var/log/mariadb/mariadb.log pid-file=/var/run/mariadb/mariadb.pid # # include all files from the config directory # !includedir /etc/my.cnf.d [client] default-character-set=utf8 socket=/data/sdv1/mydata/mysql.sock [mysql] default-character-set=utf8
5.复制数据文件
# cp -a /var/lib/mysql/* /data/sdv1/mydata/
6.启动服务
# systemctl start mariadb # systemctl status mariadb

# ll /data/sdv1/mydata/

至此,MariaDB迁移数据目录完毕!
热门排行