MySQL Install--编译安装MySQL 5.7
MySQL 编译相关选项配置和说明
[MySQL安装的根目录]
-DCMAKE_INSTALL_PREFIX=/export/servers/mysql/
[MySQL数据库文件存放目录]
-DMYSQL_DATADIR=/export/data/mysql/data/
[MySQL配置文件所在目录]
-DSYSCONFDIR=/export/servers/mysql/etc/
[MySQL用户名]
-DMYSQL_USER=mysql
[MySQL的数据库引擎]
-DWITH_MYISAM_STORAGE_ENGINE=
[MySQL的数据库引擎]
-DWITH_INNOBASE_STORAGE_ENGINE=
[MySQL的数据库引擎]
-DWITH_ARCHIVE_STORAGE_ENGINE=
[MySQL的数据库引擎]
-DWITH_MEMORY_STORAGE_ENGINE=
[MySQL的readline library]
-DWITH_READLINE=
[MySQL的通讯目录]
-DMYSQL_UNIX_ADDR=/export/data/mysql/tmp/mysql.sock
[MySQL的监听端口]
-DMYSQL_TCP_PORT=
[启用加载本地数据]
-DENABLED_LOCAL_INFILE=
[编译时允许自主下载相关文件]
-DENABLE_DOWNLOADS=
[允许使用分区]
-DWITH_PARTITION_STORAGE_ENGINE=
[使MySQL支持所有的扩展字符]
-DEXTRA_CHARSETS=all
[设置默认字符集为utf8]
-DDEFAULT_CHARSET=utf8
[设置默认字符校对]
-DDEFAULT_COLLATION=utf8_general_ci
[禁用调试模式]
-DWITH_DEBUG=
-DMYSQL_MAINTAINER_MODE=
[通讯时支持ssl协议]
-DWITH_SSL:STRING=bundled
[允许使用zlib library]
-DWITH_ZLIB:STRING=bundled
创建MySQL服务账号
## 检查和创建用户组和用户
cat /etc/passwd
##查看用户组列表
cat /etc/group
## 创建用户组mysql
groupadd mysql
## 创建mysql用户并指定用户组mysql
useradd -g mysql mysql
创建MySQL文件目录并授权
##创建mysql使用的文件夹
mkdir -p /export/data/mysql/tmp /export/data/mysql/data /export/servers/mysql/etc /export/data/mysql/dumps /export/data/mysql/log /home/mysql/scripts /home/mysql/logs /export/data/mysql/undo ##为mysql用户赋予该文件夹权限
chown -R mysql:mysql /export/data/mysql/
安装依赖包
##先安装bison-devel的rpm包
rpm -ivh bison-devel-2.4.-.el6.x86_64.rpm
##使用yum安装其他必要软件
yum -y install make gcc-c++ ncurses-devel perl-CPAN perl zlib-devel cmake
准备MySQL编译安装的boost
## 解压boost_1_59_0到/soft/boost_1_59_0目录下
## 注意不同版本MySQL可能要求不同版本的boost
tar -xvf boost_1_59_0.tar.bz2
最新源码下载:https://dev.mysql.com/downloads/mysql/5.7.html#downloads
历史源码下载:https://downloads.mysql.com/archives/community/
下载到的源码包是rpm格式,在Windows下可以直接使用压缩文件解压,MySQL 5.7版本的源码包中包含一个最新版本源码包和与之匹配的boost包。
编译安装MySQL
## 进入MySQL 源码目录
## 使用cmake来编译
cmake . -DWITH_BOOST=/soft/boost_1_59_0 \
-DCMAKE_INSTALL_PREFIX=/export/servers/mysql/ \
-DMYSQL_DATADIR=/export/data/mysql/data/ \
-DSYSCONFDIR=/export/servers/mysql/etc/ \
-DMYSQL_UNIX_ADDR=/export/data/mysql/tmp/mysql.sock \
-DMYSQL_TCP_PORT= \
-DMYSQL_USER=mysql \
-DWITH_MYISAM_STORAGE_ENGINE= \
-DWITH_INNOBASE_STORAGE_ENGINE= \
-DWITH_ARCHIVE_STORAGE_ENGINE= \
-DWITH_MEMORY_STORAGE_ENGINE= \
-DWITH_READLINE= \
-DENABLED_LOCAL_INFILE= \
-DENABLE_DOWNLOADS= \
-DWITH_PARTITION_STORAGE_ENGINE= \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_DEBUG= \
-DMYSQL_MAINTAINER_MODE= \
-DWITH_SSL:STRING=bundled \
-DWITH_ZLIB:STRING=bundled \
>> /home/mysql/logs/install-log ## 使用make && make install来编译和安装
make && make install
创建配置文件
[clent]
port = 3358
socket = /export/data/mysql/tmp/mysql.sock [mysqld]
port = 3358
socket = /export/data/mysql/tmp/mysql.sock
datadir = /export/data/mysql/data/ #--- GLOBAL ---#
log_timestamps = SYSTEM
character-set-server = utf8
lower_case_table_names = 1
log-output = FILE
log-error = /export/data/mysql/log/error.log
#general_log
#general_log_file = /export/data/mysql/log/mysql.log
pid-file = /export/data/mysql/mysql.pid
slow-query-log
slow_query_log_file = /export/data/mysql/log/slow.log
tmpdir = /export/data/mysql/tmp
long_query_time = 0.1
sync_binlog = 1
log_timestamps = SYSTEM
#--------------# #thread_concurrency = 16
thread_cache_size = 512
table_open_cache = 16384
table_definition_cache = 16384
sort_buffer_size = 4M
join_buffer_size = 4M
read_buffer_size = 4M
read_rnd_buffer_size = 4M
key_buffer_size = 64M
myisam_sort_buffer_size = 64M
tmp_table_size = 32M
max_heap_table_size = 32M
open_files_limit = 65535
query_cache_size = 0
query_cache_type = 0
bulk_insert_buffer_size = 64M
binlog_rows_query_log_events =on
sql_mode = STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION #--- NETWORK ---#
back_log = 1024
max_allowed_packet = 256M
interactive_timeout = 28800
wait_timeout = 28800
skip-external-locking
max-connections = 1000
skip-name-resolve = 1
read_only = 0
#--- REPL ---#
server-id = ${server_id}
log-bin = mysql-bin
master_info_repository = TABLE
binlog_format = ROW
expire_logs_days = 7
log_slave_updates = 1 slave-parallel-workers = 8
slave-parallel-type = LOGICAL_CLOCK
slave_preserve_commit_order = 0 skip-slave-start
gtid_mode = on
enforce-gtid-consistency = true relay-log = relay-log
relay_log_recovery = ON
sync_relay_log = 0
relay_log_info_repository = TABLE #--- INNODB ---#
default-storage-engine = INNODB
innodb_data_home_dir = /export/data/mysql/data
innodb_data_file_path = ibdata1:1024M:autoextend
innodb_file_per_table
innodb_log_group_home_dir = /export/data/mysql/data
innodb_buffer_pool_size = ${innodb_buffer_pool_size}G
#innodb_additional_mem_pool_size = 128M
innodb_log_files_in_group = 3
innodb_log_file_size = 1024M
innodb_log_buffer_size = 16M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 120
innodb_flush_method = O_DIRECT
innodb_max_dirty_pages_pct = 75
innodb_io_capacity = 1000
#innodb_thread_concurrency = 32
innodb_open_files = 65535
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_print_all_deadlocks = 1
innodb_undo_directory = /export/data/mysql/undo
innodb_undo_tablespaces = 4
innodb_purge_threads = 4
innodb_purge_batch_size = 400
innodb_stats_on_metadata = 0 [mysqldump]
#quick
max_allowed_packet = 256M [mysql]
# auto-rehash
# Remove the next comment character if you are not familiar with SQL
# safe-updates
default-character-set=utf8 [myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M [mysqlhotcopy]
interactive-timeout
修改上面文件中变量server_id和innodb_buffer_pool_size的值,并将文件保存到export/servers/mysql/etc/my.cnf
初始化系统数据库
## 执行初始化配置脚本,创建系统自带的数据库和表
/export/servers/mysql/bin/mysqld \
--user=mysql \
--basedir=/export/servers/mysql/ \
--datadir=/export/data/mysql/data/ \
--initialize-insecure --initialize
参考链接:https://dev.mysql.com/doc/refman/5.7/en/mysql-install-db.html#option_mysql_install_db_defaults-file
启动MySQL服务
--启动数据库, 测试数据库是否能正常启动
/export/servers/mysql/bin/mysqld_safe --defaults-file=/export/servers/mysql/etc/my.cnf &
创建MySQL数据库账号
/export/servers/mysql/bin/mysql \
--socket="/export/data/mysql/tmp/mysql.sock" \
-uroot -e " ## 创建mysql_admin管理员账号
GRANT ALL PRIVILEGES ON *.* TO 'mysql_admin'@'%' IDENTIFIED BY 'mysql_admin' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'mysql_admin'@'localhost' IDENTIFIED BY 'mysql_admin' WITH GRANT OPTION; ## 清理账号
SET @@session.binlog_format = 'statement'; DELETE FROM mysql.user
WHERE user = ''; DELETE FROM mysql.user
WHERE authentication_string = '';
SET @@session.binlog_format = 'row'; "
设置开机启动:
## 编辑文件
vi /etc/rc.d/rc.local ## 添加如下内容
/export/servers/mysql/bin/mysqld_safe \
--defaults-file=/export/servers/mysql/etc/my.cnf &
在CentOS7版本中,/etc/rc.d/rc.local的权限较低,需要给该文件增加可执行权限
chmod +x /etc/rc.d/rc.local
创建快速登录脚本
## 编辑登录脚本
vim /usr/local/bin/mysql_login ## 插入下面代码
#!/usr/bin/env bash
mysql_bin="/export/servers/mysql/bin/mysql"
mysql_user='mysql_admin'
mysql_password='mysql_admin'
mysql_host='127.0.0.1'
mysql_port=3358 $mysql_bin --host="${mysql_host}" \
--port=${mysql_port} \
--user="${mysql_user}" \
--password="${mysql_password}" \
--safe-updates \
--select-limit=1000000 \
--init-command="set autocommit=0" \
--prompt="\u@\h:\d>" ## 为登录脚本授权
chmod +x /usr/local/bin/mysql_login
MySQL Install--编译安装MySQL 5.7的更多相关文章
- Linux(CentOS6.5)下编译安装MySQL Community Server 5.7.12
组件 官方网站 直接下载地址 备注 mysql http://dev.mysql.com/downloads/mysql/ http://mirrors.sohu.com/mysql/MySQL- ...
- CentOS源码编译安装MySQL 5.5.15
CentOS源码编译安装MySQL 5.5.15 文章目录 [隐藏] 安装编译工具 下载源码 安装cmake和bison 编译安装MySQL 一些相关设置 安装编译工具 yum install g ...
- 源码编译安装 MySQL 5.5.x 实践
1.安装cmakeMySQL从5.5版本开始,通过./configure进行编译配置方式已经被取消,取而代之的是cmake工具.因此,我们首先要在系统中源码编译安装cmake工具. # wget ht ...
- shell脚本专题之-----------全自动编译安装mysql
mysql的编译安装,在博客 开源服务专题之--------mysql的编译安装 中已经说明了,但是还是比较麻烦,尤其是一大堆命令,来手动执行,稍有不慎,就会出错.生产上一般都是先在本地测试环境进行自 ...
- CentOS 编译安装 mysql
1.前期准备 1.1 环境说明: 操作系统: CentOS release 6.4 (Final) [查看命令 cat /etc/redhat-release ] mysql : mysql-5.6. ...
- Linux CentOS6.5下编译安装MySQL 5.6.16【给力详细教程】
一.编译安装MySQL前的准备工作 安装编译源码所需的工具和库 yum install gcc gcc-c++ ncurses-devel perl 安装cmake,从http://www.cmake ...
- Linux编译安装Mysql步骤
一. Centos 用 wget 下载需要的软件,保存到目录/home/zwl/MySql/下 wget http://dev.mysql.com/get/Downloads/MySQL-5.5/my ...
- CentOS下编译安装MySQL 5.6.21
一.编译安装MySQL前的准备工作 安装编译源码所需的工具和库 yum install gcc gcc-c++ ncurses-devel perl 安装cmake:http://www.cnblog ...
- 源码编译安装 MySQL 5.5.x 实践(转)
1.安装cmakeMySQL从5.5版本开始,通过./configure进行编译配置方式已经被取消,取而代之的是cmake工具.因此,我们首先要在系统中源码编译安装cmake工具. # wget ht ...
- Linux 环境编译安装mysql (源码安装包)
标注: Linux需要先配置网络yum源,确定yum能在线安装软件包,方便测试过程中安装部分依赖包.配置163网易提示的网络yum源参考博客 http://www.cnblogs.com/zoulo ...
随机推荐
- centos6.9安装python3.6.9独立的virtualenv环境,并且能正确引入ssl
centos6.9安装python3.6.9独立的virtualenv环境,并且能正确引入ssl 1.编译安装python3.6环境# 安装依赖yum -y install zlib-devel bz ...
- python |elasticsearchs操作es的例子
from elasticsearch import Elasticsearch import json import time es = Elasticsearch(['es地址:9200'],ign ...
- StandardServer.await: Invalid command '' received
tomcat服务运行时 后台提输出警告:StandardServer.await: Invalid command '' received 这个警告是 多个tomcat启动时会出现端口占用的情况, 将 ...
- Redis常用运维命令
1.启动命令 按照我其他博客的按照方法,启动命令为/etc/init.d/redis_6379 start 2.查看内存统计信息 [root@bogon ~]# redis-cli > info ...
- C# .net 提升 asp.net mvc, asp.net core mvc 并发量
1.提升System.Net.ServicePointManager.DefaultConnectionLimit 2.提升最小工作线程数 ------ DefaultConnectionLimit在 ...
- kafka 如何保证数据不丢失
一般我们在用到这种消息中件的时候,肯定会考虑要怎样才能保证数据不丢失,在面试中也会问到相关的问题.但凡遇到这种问题,是指3个方面的数据不丢失,即:producer consumer 端数据不丢失 b ...
- js中Boolean类型和Number类型的一些常见方法
Boolean类型 Boolean类型重写了valueOf() 方法, 返回基本布尔类型值true或false,重写了toString() 方法,返回基本字符串"true" 和 & ...
- 单选 textarea 赋初值
自闭合标签赋初值用$().val(),比如:<input type="text" name="text" value="123"> ...
- Django框架(十一)--cookie和session
cookie和session组件 cookie 1.cookie的由来 大家都知道HTTP协议是无状态的. 无状态的意思是每次请求都是独立的,它的执行情况和结果与前面的请求和之后的请求都无直接关系,它 ...
- Golang 读写文件
读文件 func ReadFile_v1(filename string) { var ( err error content []byte ) fileObj,err := os.Open(file ...