源码包编译安装MariaDB-10.1.22
1、获取源码包
mariadb-10.1.22.tar.gz
2、编译环境及依赖关系
yum groupinstall -y Development Tools
yum -y install gcc gcc-c++ make cmake ncurses ncurses-devel man ncurses libxml2 libxml2-devel openssl-devel bison bison-devel
3、创建mysql用户
~]# groupadd mysql
~]# useradd -s /sbin/nologin -g mysql -M mysql
~]# id mysql
uid=500(mysql) gid=500(mysql) 组=500(mysql)
~]# ~]# mkdir /mydata/data -pv
~]# chown mysql:mysql /mydata/data/ -R
4、编译安装mariadb-10.1.22
解压源码包:
~]# tar xf mariadb-10.1.22.tar.gz
编译安装MariaDB:
~]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/mydata/data \
-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
参考:https://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html
~]# make -j 4
~]# make install
5、配置安装MariaDB
~]# cd /usr/local/mysql/
~]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data
~]# ls /mydata/data/
aria_log.00000001 ib_logfile0 mysql performance_schema test-jian.pid
aria_log_control ib_logfile1 mysql-bin.000001 test
ibdata1 multi-master.info mysql-bin.index test-jian.err
6、MariaDB配置文件创建及更改,有模版
~]# mkdir /etc/mysql
~]# cp support-files/my-large.cnf /etc/mysql/my.cnf
~]# vim /etc/mysql/my.cnf
[mysqld]
port = 3306
datadir = /mydata/data
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8
innodb_file_per_table = on
skip_name_resolve = on
创建服务脚本:
~]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
~]# chkconfig --list mysqld
~]# chkconfig --add mysqld
启动mysqld服务,测试启动:
~]# service mysqld start
7、设置环境变量
~]# vim /etc/profile.d/mysqld.sh
MYSQL_HOME=/usr/local/mysql
export PATH=$MYSQL_HOME/bin:$PATH
加载环境变量:
~]# source /etc/profile.d/mysqld.sh
连接MySQL:
~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.1.22-MariaDB Source distribution
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
原创文章,作者:641348038@qq.com,如若转载,请注明出处:http://www.178linux.com/71200


评论列表(1条)
非常详细的使用介绍,加油。