修改 Mariadb 存储路径

Mariadb  

安装Mariadb

yum install -y epel-release  
yum install -y mariadb-server mariadb-devel  
service mariadb start  
chkconfig mariadb on  

创建存储目录

mkdir /data/mysql/data  
chown -R mysql:mysql /data/mysql/data  
cp -a /var/lib/mysql/*    /data/mysql/data/  

修改配置文件/etc/my.cnf(1C2G为例)

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log  
pid-file=/var/run/mariadb/mariadb.pid

[client]
port    = 3306  
socket  = /tmp/mysql.sock

[mysqld]
#skip-locking
symbolic-links=0  
skip-name-resolve  
#basedir = /usr/local/mysql
datadir = /data/mysql/data  
bind-address = 127.0.0.1  
port = 3306  
server_id = 1  
socket = /tmp/mysql.sock  
back_log = 100  
max_allowed_packet = 32M  
sort_buffer_size = 1M  
join_buffer_size = 1M  
read_rnd_buffer_size = 2M  
#sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
#binlog
binlog-ignore-db=test  
replicate-ignore-db=test  
log-bin=mysql-bin  
binlog_cache_size = 3M  
binlog_format=mixed  
expire_logs_days=7  

重新启动Mariadb

service mariadb restart  

查看进程,确认已经修改

mysql      435  0.0  0.0 113260  1592 ?        Ss   09:32   0:00 /bin/sh /usr/bin/mysqld_safe --basedir=/usr  
mysql      798  0.0  4.5 837664 85880 ?        Sl   09:32   0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/data/mysql/data --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/tmp/mysql.sock --port=3306  
root      1747  0.0  0.0 112660   976 pts/1    R+   09:41   0:00 grep --color=auto mysql