centos6.5下编译安装mariadb-10.0.20

源码编译安装mariadb-10.0.20.tar.gz

一.安装cmake编译工具

跨平台编译器
# yum install -y gcc*
# yum install -y cmake
解决依赖关系
# yum install -y readline-devel zlib-devel openssl-devel
# yum install -y libaio perl perl-DBI perl-Module-Pluggable perl-Pod-Escapes perl-Pod-Simple perl-libs perl-version
# yum install -y ncurses ncurses libxml2 libxml2-devel bison bison-devel

二、编译安装mariadb-10.0.20



# tar xf mariadb-10.0.20.tar.gz
# cd mariadb-10.0.20
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mydata -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
centos6.5下编译安装mariadb-10.0.20_第1张图片

# make && make install

centos6.5下编译安装mariadb-10.0.20_第2张图片

创建mysql数据存储的目录
# mkdir -pv /data/mydata


划分一个大小为10G的逻辑卷存储mysql数据,将该卷挂载在/data/mydata目录下
# lvcreate -n mylv -L 10G /dev/myvg
# mke2fs -t ext4 /dev/myvg/mylv

centos6.5下编译安装mariadb-10.0.20_第3张图片

三、创建Mysql用户

//制定组id和用户id为306
# groupadd -r -g 306 mysql
# useradd -g mysql -r -g 306 -s /sbin/nologin mysql
验证
# id mysql



改变数据存储目录和安装目录的权限
# cd /usr/local/mysql
# chown -R :mysql ./*
# chown -R mysql.mysql /data/mydata


四、启动脚本初始化数据库

# scripts/mysql_install_db --user=mysql --datadir=/data/mydata
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# cp support-files/my-large.cnf /etc/my.cnf

编辑/etc/my.cnf加入

innodb_file_per_table = ON

datadir = /data/mydata

log-bin=/data/binlogs/mysql-bin


centos6.5下编译安装mariadb-10.0.20_第4张图片


加入到服务器启动项
# chkconfig --add mysqld
# chkconfig --list mysqld



将mysql命令加入环境变量中
vim /etc/profile.d/mysql.sh
加入
export PATH=/usr/local/mysql/bin:$PATH




# service mysqld start

# ss -tnl

centos6.5下编译安装mariadb-10.0.20_第5张图片

初始化
MariaDB [(none)]> use mysql;


删除匿名用户:
MariaDB [mysql]> delete from user where host='localhost' and user='';


MariaDB [mysql]> delete from user where host='centossz008' and user='';


MariaDB [mysql]> delete from user where host='::1' and user='root';

 

你可能感兴趣的:(centos6.5下编译安装mariadb-10.0.20)