系统 : CentOS 6.9 x64 mini
MariaDB版本 : mariadb 10.2.6
安装目录 : /www/server/mariadb
懒人命令 保存为 .sh 并设置 执行权限 即可. 经过实际测试,
#!/bin/sh
# Auther: Mr.G Mail:cmaoge@126.com
# QQ:825312600
# Date:2017.08.09
# Mariadb Install For CentOSyum install -y ncurses-devel make cmake bison zlib zlib-devel openssl openssl-devel jemalloc gcc gcc-c++ cmake
tar zxvf mariadb-10.2.6.tar.gz
cd mariadb-10.2.6cmake . -DCMAKE_INSTALL_PREFIX=/www/server/mariadb \
-DDEFAULT_SYSCONFDIR=/www/server/mariadb/etc -DMYSQL_DATADIR=/www/server/mariadb/data \
-DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/www/server/mariadb/mariadb.sock \
-DMYSQL_USER=mariadb -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 \
-DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0make && make install
groupadd mariadb
useradd -s /sbin/nologin -M -g mariadb mariadb
mkdir -p /www/server/mariadb/etc
mkdir -p /www/server/mariadb/log
mkdir -p /www/server/mariadb/run
mkdir -p /www/server/mariadb/init.d
rm -f /www/server/mariadb/etc/my.cnfcp /www/soft/mariadb-10.2.6/support-files/my-large.cnf.sh /www/server/mariadb/etc/my.cnf
sed -i "20,30s/@MYSQL_TCP_PORT@/3306/g" /www/server/mariadb/etc/my.cnf
sed -i "20,30s/@MYSQL_UNIX_ADDR@/\/www\/server\/mariadb\/mariadb.sock/g" /www/server/mariadb/etc/my.cnf
sed -i "N;30a\character_set_server = utf8" /www/server/mariadb/etc/my.cnf
sed -i "N;30a\log-error = /www/server/mariadb/log/mariadb.log" /www/server/mariadb/etc/my.cnf
sed -i "N;30a\pid-file = /www/server/mariadb/run/mariadb.pid" /www/server/mariadb/etc/my.cnf
sed -i "N;22a\default-character-set = utf8" /www/server/mariadb/etc/my.cnf
chown -R mariadb.mariadb /www/server/mariadb/
/www/server/mariadb/scripts/mysql_install_db --user=mariadb --basedir=/www/server/mariadb/ --datadir=/www/server/mariadb/data
cp /www/soft/mariadb-10.2.6/support-files/mysql.server /www/server/mariadb/init.d/mariadb
ln -sf /www/server/mariadb/init.d/mariadb /etc/init.d/mariadb
chmod 755 /etc/init.d/mariadb
chkconfig --add mariadb
chkconfig mariadb onsed -i "46s/basedir=/basedir=\/www\/server\/mariadb/" /www/server/mariadb/init.d/mariadb
sed -i "47s/datadir=/datadir=\/www\/server\/mariadb\/data/" /www/server/mariadb/init.d/mariadb
sed -i "63s/mysqld_pid_file_path=/mysqld_pid_file_path=\/www\/server\/mariadb\/run\/mariadb.pid/" /www/server/mariadb/init.d/mariadbln -sf /www/server/mariadb/bin/mysql /usr/bin/mysql
ln -sf /www/server/mariadb/bin/mysqladmin /usr/bin/mysqladmin
ln -sf /www/server/mariadb/bin/mysqldump /usr/bin/mysqldump|
ln -sf /www/server/mariadb/bin/myisamchk /usr/bin/myisamchk
ln -sf /www/server/mariadb/bin/mysqld_safe /usr/bin/mysqld_safe
ln -sf /www/server/mariadb/bin/mysqlcheck /usr/bin/mysqlcheck
sed -i "30s/user='mysql'/user='mariadb'/" /www/server/mariadb/bin/mysqld_safe