service mysqld stop
cd /usr/local/src
wget https://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.2.14/bintar-linux-glibc_214-x86_64/mariadb-10.2.14-linux-glibc_214-x86_64.tar.gz
tar zxvf mariadb-10.2.14-linux-glibc_214-x86_64.tar.gz
mv mariadb-10.2.14-linux-glibc_214-x86_64 /usr/local/mariadb
cd /usr/local/mariadb
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb/ --datadir=/data/mariadb
echo $? //检查是否成功,0
cp support-files/my-small.cnf /usr/local/mariadb/my.cnf //由于之前安装mysql时已经用了/etc/my.cnf ,所以这里另外选一个路径 ,support-files/下有很多.cnf模板文件,基本是配置差别,这里选my-small.cnf即可
vi /usr/local/mariadb/my.cnf //定义basedir和datadir
配置文件中要在mysqld下面修改配置文件
datadir=/data/mariadb
basedir=/usr/local/mariadb
cp support-files/mysql.server /etc/init.d/mariadb
vim /etc/init.d/mariadb //定义basedir、datadir、conf以及启动参数
定义basedir、datadir、conf
然后在下面start配置修改启动参数
--defaults-file="$cnf"
/etc/init.d/mariadb start //开启mariadb
service mariadb stop //关闭mariadb
原文地址:http://blog.51cto.com/13569831/2096741