> CentOS > CentOS服务器 > 环境配置 >

CentOS7下源码安装MariaDB10.0.12

代码很乱!下一步研究一下代码片

准备环境:

最小化安装CentOS7、gcc、gcc-c++、bison、ncurses、ncurses-devel、zlib-devel

下载MariaDB10.0.12源码包:

cd /usr/local/src

wget http://ftp.kaist.ac.kr/mariadb/mariadb-10.0.12/source/mariadb-10.0.12.tar.gz

useradd -M -s /sbin/nologin mysql

mkdir -p /data/mariadb

chown -R mysql.mysql /data/mariadb

tar zxvf mariadb-10.0.12.tar.gz

cd mariadb-10.0.12

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb \
-DMYSQL_DATADIR=/data/mariadb \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DWITH_XTRADB_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EXTRA_CHARSETS=1 \
-DWITH_SSL=bundled \
-DWITH_ZLIB=bundled

make && make install

cd /usr/local/mariadb/support-files

cp my-small.cnf /etc/my.cnf

修改my.cnf配置,增加以下几行:

basedir=/usr/local/mariadb

datadir=/data/mariadb

pid-file=/data/mariadb/mariadb.pid

log-error=/data/mariadb/mariadb.err

将服务器启动文件加入到系统启动中:

cp mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld

chkconfig --add mysqld

chkconfig mysqld on

bin目录加入path

echo 'export PATH=$PATH:/usr/local/mariadb/bin' >>/etc/profile

创建数据库:

cd /usr/local/mariadb/scripts

./mysql_install_db --user=mysql --basedir=/usr/local/mariadb datadir=/data/mariadb

chown -R mysql:mysql /data/mariadb

 
(责任编辑:IT)