阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 7 编译安装MariaDB-10.1.22

240次阅读
没有评论

共计 4129 个字符,预计需要花费 11 分钟才能阅读完成。

CentOS 7 下 mariadb-10.1.22 源码编译安装过程笔记,希望对大家有帮助。

下载文件 https://mariadb.com/
1. 安装开发环境
yum groupinstall “Development Tools”

安装需要包:
yum install -y ncurses-devel openssl-devel openssl

2. 安装 cmake
tar -xf cmake-3.8.0.tar.gz
cd cmake-3.8.0
./bootstrap
make
make install

3. 安装前准备
3.1. 准备目录
mkdir -pv /data/mysql/3306/{data,logs/{binlog,relaylog}}

3.2. 添加用户
groupadd mysql
useradd -s /sbin/nologin -g mysql -M mysql
chown mysql:mysql /data/mysql/3306/ -R

4. 编译安装
# tar -xf mariadb-10.1.22.tar.gz 
# cd mariadb-10.1.22
# cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql/3306/data \
-DSYSCONFDIR=/etc \
-DMYSQL_USER=mysql \
-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 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1  \
-DWITH_DEBUG=0 \
-DWITHOUT_MROONGA_STORAGE_ENGINE=1
# make
# make install

5. 安装完环境准备
# chmod +w /usr/local/mysql/
# chown -R mysql:mysql /usr/local/mysql/

6. 拷贝配置文件并修改
# cp support-files/my-large.cnf /etc/my.cnf

# vim /etc/my.cnf

增加如下:
datadir = /data/mysql/3306/data
innodb_flush_log_at_trx_commit = 2
innodb_file_per_table = ON
skip_name_resolve = ON

查看配置文件:
vim /etc/my.cnf
[client]
port            = 3306
socket          = /tmp/mysql.sock
 
[mysqld]
port            = 3306
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
thread_concurrency = 8
 
log-bin=mysql-bin
binlog_format=mixed
server-id      = 1
datadir = /data/mysql/3306/data
innodb_data_home_dir = /data/mysql/3306/data
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /data/mysql/3306/data
innodb_buffer_pool_size = 256M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size = 64M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 50
innodb_file_per_table = ON
skip_name_resolve = ON
 
[mysqldump]
quick
max_allowed_packet = 16M
 
[mysql]
no-auto-rehash
 
[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
 
[mysqlhotcopy]
interactive-timeout

7. 初始化 mysql
# scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql/ –datadir=/data/mysql/3306/data/ –defaults-file=/etc/my.cnf

查看初始化结果:
# ls /data/mysql/3306/data/
aria_log.00000001  ibdata1      ib_logfile1  mysql-bin.000001  mysql-bin.000003  mysql-bin.state    test
aria_log_control  ib_logfile0  mysql        mysql-bin.000002  mysql-bin.index  performance_schema

8. 启动服务
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod +x /etc/rc.d/init.d/mysqld 
# chkconfig –add mysqld
# service mysqld start

9. 添加环境变量
# vim /etc/profile
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin

重读环境变量
source /etc/profile

10. 初始化数据库用户表
# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
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)]> use mysql
Database changed
MariaDB [mysql]> delete from user where host=’localhost.localdomain’ or host=’127.0.0.1′ or host=’::1′ or user=”;
Query OK, 5 rows affected (0.00 sec)

Ubuntu 16.04 LTS 上安装 Nginx、MariaDB 和 HHVM 运行 WordPress  http://www.linuxidc.com/Linux/2016-10/136435.htm

Ubuntu 16.04 Dockerfile 安装 MariaDB  http://www.linuxidc.com/Linux/2016-09/135260.htm

Linux 系统教程:如何检查 MariaDB 服务端版本  http://www.linuxidc.com/Linux/2015-08/122382.htm

Ubuntu 16.04 下如何安装 MariaDB  http://www.linuxidc.com/Linux/2017-04/142915.htm

Linux 下编译安装配置 MariaDB 数据库的方法 http://www.linuxidc.com/Linux/2014-11/109049.htm

CentOS 系统使用 yum 安装 MariaDB 数据库 http://www.linuxidc.com/Linux/2014-11/109048.htm

安装 MariaDB 与 MySQL 并存 http://www.linuxidc.com/Linux/2014-11/109047.htm

Ubuntu 上如何将 MySQL 5.5 数据库迁移到 MariaDB 10  http://www.linuxidc.com/Linux/2014-11/109471.htm

[翻译]Ubuntu 14.04 (Trusty) Server 安装 MariaDB  http://www.linuxidc.com/Linux/2014-12/110048htm

Ubuntu 14.04(Trusty) 安装 MariaDB 10 数据库  http://www.linuxidc.com/Linux/2016-11/136833.htm

MariaDB 的详细介绍 :请点这里
MariaDB 的下载地址 :请点这里

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2017-05/143291.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-22发表,共计4129字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中