Mysql 之 编译安装方法(Mysql5.7)

参考本博客文章:
http://blog.51cto.com/12965094/2129267

1. 下载安装包
wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21.tar.gz

2.安装依赖包
yum -y install gcc gcc-c++ ncurses ncurses-devel cmake

3.添加mysql 用户与组
groupadd mysql
useradd -r -g mysql mysql

4.新建MYSQL的安装目录,与数据存放目录
mkdir -p /app/mysql
mkdir -p /app/data

5.解压安装
tar -zxvf boost_1_59_0.tar.gz
tar -zxvf mysql-5.7.21.tar.gz
cd mysql-5.7.21      #进入mysql的解压目录

6.使用cmake 编译mysql
cmake . -DCMAKE_INSTALL_PREFIX=/app/mysql -DMYSQL_DATADIR=/app/data -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/root/boost_1_59_0 -DSYSCONFDIR=/etc \-DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DENABLE_DTRACE=0 -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_EMBEDDED_SERVER=1

7.编译安装mysql
make && make install

8.设置开机自动启动脚本
cp /app/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on

9.修改MYSQL的环境变量
vi /etc/profile
export PATH=$PATH:/app/mysql/bin
source /etc/profile

10.修改MYSQL所在目录权限
chown -R mysql:mysql /app/mysql

11.初始化MYSQL数据库
[[email protected] ~]# /app/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/app/mysql --datadir=/app/mysql/data
2018-03-26T07:31:17.298033Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-03-26T07:31:18.332278Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-03-26T07:31:18.436844Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-03-26T07:31:18.453099Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: ac7149bc-30c7-11e8-999a-005056804f18.
2018-03-26T07:31:18.458082Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.
2018-03-26T07:31:18.458468Z 1 [Warning] [email protected] is created with an empty password ! Please consider switching off the --initialize-insecure option.
[[email protected] ~]# ll /app/data/
total 110620
-rw-r-----. 1 mysql mysql       56 Mar 26 15:31 auto.cnf
-rw-r-----. 1 mysql mysql      420 Mar 26 15:31 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 Mar 26 15:31 ibdata1
-rw-r-----. 1 mysql mysql 50331648 Mar 26 15:31 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 Mar 26 15:31 ib_logfile1
drwxr-x---. 2 mysql mysql     4096 Mar 26 15:31 mysql
drwxr-x---. 2 mysql mysql     4096 Mar 26 15:31 performance_schema
drwxr-x---. 2 mysql mysql    12288 Mar 26 15:31 sys

12.修改配置文件,如下:
vi /etc/my.cnf
[client]
port=3306
socket=/tmp/mysql.sock

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
user = mysql
basedir = /app/mysql
datadir = /app/mysql/data
port=3306
server-id = 1
socket=/tmp/mysql.sock

character-set-server = utf8
#log-error = /var/log/mysql/error.log
#pid-file = /var/log/mysql/mysql.pid
general_log = 1
skip-name-resolve
#skip-networking
back_log = 300

max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M

read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 28M
key_buffer_size = 4M

thread_cache_size = 8

query_cache_type = 1
query_cache_size = 8M
query_cache_limit = 2M

ft_min_word_len = 4

log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 30

performance_schema = 0
explicit_defaults_for_timestamp

#lower_case_table_names = 1

myisam_sort_buffer_size = 8M
myisam_repair_threads = 1

interactive_timeout = 28800
wait_timeout = 28800

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Recommended in standard MySQL setup
sql_mode=NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER,STRICT_TRANS_TABLES

[mysqldump]
quick
max_allowed_packet = 16M

13.创建错误日志与PID存放位置
mkdir -p /var/log/mysql/
chown -R mysql:mysql /var/log/mysql/

14.启动mysql
[[email protected] mysql]# service mysqld start
Starting MySQL.[  OK  ]
[[email protected] mysql]# netstat -tlnp | grep 3306
tcp        0      0 :::3306                     :::*                        LISTEN      27565/mysqld

原文地址:http://blog.51cto.com/12965094/2163419

时间: 2024-08-25 03:15:21

Mysql 之 编译安装方法(Mysql5.7)的相关文章

Mysql快速配置安装方法

一. 前言 由于mysql 5.5.7之后使用cmake编译.本篇简单介绍mysql的安装和配置. 二. 环境准备 1.操作系统 CentOS 6.4 x86_64 2.软件版本 mysql-5.5.37   #下载地址:http://dev.mysql.com/downloads/file.php?id=451429 ,需要申请oracle账号才能下载. 3.需要安装的依赖包 cmake gcc gcc-c++ ncurses-devel bison openssl-devel 4. 安装过程

MySQL数据库多种安装方法及企业级安装实践

本文来自老男孩老师第三本书籍著作<老男孩的MySQL私房菜>第三章内容分享! 3.1 MySQL数据库的安装方法及选择 在当今的互联网企业里,MySQL数据库大多运行在Linux系列操作系统上,当然,你也可以运行在Windows/Unix等商业操作系统上,本书主要以国内互联网公司应用最多的数据库服务操作系统--CentOS6最新版(6.8)x86_64 Linux系统为例进行讲解,使用其他系统的读者同样可以从本书受益! 即使是在CentOS 6 x86_64 Linux系统环境下,若应用场景不

apache/mysql/php编译安装及支持xcache和fastcgi方式运行

一.编译安装apache     1.安装环境:yum install gcc gcc-c++ openssl-devel libtool -y     2.安装apr.apr-util及pcre         tar jxf apr-1.5.1.tar.bz2         cd apr-1.5.1         ./configure --prefix=/usr/local/apr         make && make install              tar jxf

Linux之mysql的编译安装(1)

centos6.6 编译安装MySQL5.6 [本文档所介绍的内容适用于公司测试/生产等常见的MySQL数据库环境部署] 一:环境部署前准备: 1.1相关软件以及系统 系统要求:Centos 6.6 (64位) 相关中间件:  mysql-5.6.23 1.2相关系统依赖包安装检查准备 1.2.1 检查系统自带mysql是否安装 # rpm -qa | grep mysql 如有安装,请使用以下命令卸载相关程序 # yum remove  mysql 1.2.2 安装系统相关的编译环境:mysq

CentOS6.5-源码编译安装最新MySQL5.7.10

接着使用YUM方式安装mysql后,本文将介绍下在CentOS6.5 64位虚拟机上通过编译源码安装MYSQL5.7.10服务. 环境: OS: CentOS6.5 x86_64 最小化安装 CPU: 1 MEM: 1G 注:上面的CPU/MEM参数太小了,编译时间会很长,很长... 1. 准备编译安装依赖环境 shell> yum install gcc gcc-c++ cmake ncurses ncurses-devel -y # 5.7.5后,依赖boost工具,GEO支持 shell>

mysql的编译安装

Mysql 一.Mysql的编译安装 1.安装环境以及安装包的准备 Mysql的安装环境需要占用很大的内存,所以把cpu核数增添到了两个,把内存至少加到2048以上 安装包: 安装这个是为了编译用 Mysql的安装包 2.由于安转前要扩大内存,所以要扩充容量,如果根分区的形式时LVM才可以扩容,这个也是之后安装系统要注意的,尽量在安装系统时就将根分区设置成为LVM,这样才可以添加扩容,由于本次装机时没有采取该方式,所以只能重新添加一块虚拟磁盘,将其设成LVM方式,将其挂载到本机的一个目录下.如下

【Vegas原创】Mysql绿色版安装方法

原文:[Vegas原创]Mysql绿色版安装方法 所谓的绿色版,就是没有installer的MySQL,完全需要靠人工来操作,好处是,重装系统后,只要再做一次本次配置,即可使用. 具体操作方法: 1,设置系统环境变量, 在Path中添加 D:\mysql\bin 2,修改my-small.ini文件内容,添加以下内容 basedir=D:\mysql datadir=D:\mysql\data 修改后,另存为my.ini 3.安装MySQL的服务,服务名自己定义为MySQL. 1).进入DOS窗

apache-2.4.x 编译安装方法

apache-2.4.x 编译安装方法 作者:朱 茂海 /分类:Apache 字号:L M S apache-2.2与新出的apache-2.4安装不同的地方在于,2.4版的已经不自带apr库,所以在安装apache-2.4之前,需要下载apr. 1.下载软件 cd /tmp wget http://mirrors.axint.net/apache//httpd/httpd-2.4.2.tar.gz wget http://mirrors.axint.net/apache//apr/apr-1.

MySQL(4)——编译安装MySQL-5.5.33

MySQL的安装方式: (一)二进制格式安装: RPM安装包: OS Vendor,比如Red Hat官方提供的rpm包 MySQL官方提供的rpm包 通用二进制安装包: (二)源码包编译方式安装: MySQL的版本选择: 就目前为止,一般使用5.5的居多,它既具有新版本的许多特性(就像RHEL的2.6内核具有3.x内核的特性一样),又兼具5.1版本的使用风格. 但是目前官方在维护还有很多版本比如5.1.5.6.6.x 为毛需要编译安装? 由于二进制格式的包是在比较通用的平台上进行编译完成的,所