CentOS 编译安装 MySQL5.7

下载

所有版本下载地址: http://dev.mysql.com/downloads/mysql/

此处用 5.7.10

wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.10.tar.gz

安装依赖包

yum -y install gcc gcc-c++ ncurses ncurses-devel cmake

添加mysql用户和组

useradd -M -s /sbin/nologin mysql

预编译

cd mysql-5.7.10
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DDOWNLOAD_BOOST=1 -DWITH_BOOST=boost/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

编译安装

make -j `grep processor /proc/cpuinfo | wc -l`
make install

启动脚本,设置开机自启动

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on

初始化数据库

注:

  • 之前版本mysql_install_db是在mysql_basedir/script下,5.7放在了mysql_install_db/bin目录下,且已被废弃
  • --initialize 会生成一个随机密码(~/.mysql_secret),而 --initialize-insecure 不会生成密码
  • —datadir 目标目录下不能有数据文件
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql 

/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

编辑配置文件

/etc/my.cnf

参考配置:

[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8mb4
[mysqld]
port = 3306
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /data/mysql
pid-file = /data/mysql/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 1
init-connect = ‘SET NAMES utf8mb4‘
character-set-server = utf8mb4
#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 = 8M
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
log_error = /data/mysql/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mysql/mysql-slow.log
performance_schema = 0
explicit_defaults_for_timestamp
#lower_case_table_names = 1
skip-external-locking
default_storage_engine = InnoDB
#default-storage-engine = MyISAM
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
interactive_timeout = 28800
wait_timeout = 28800
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M

设置数据库密码

# 数据库root密码
/usr/local/mysql/bin/mysql -e "grant all privileges on *.* to [email protected]‘127.0.0.1‘ identified by \"123456\" with grant option;"

/usr/local/mysql/bin/mysql -e "grant all privileges on *.* to [email protected]‘localhost‘ identified by \"123456\" with grant option;"
时间: 2024-11-05 18:32:04

CentOS 编译安装 MySQL5.7的相关文章

centos编译安装php5.6.20+nginx1.8.1+mysql5.6.17

LNMP 代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构. 本次实践需求: 实践centos6.5编译安装 LNMP生产环境 架构 web生产环境 使用 xcache 优化php 作为 Web 服务器:相比 Apache,Nginx 使用更少的资源,支持更多的并发连接,体现更高的效率. 作为负载均衡服务器:Nginx既可以在内部直接支持Rails和PHP,也可以支持作为 HTTP代理服务器对外进行服务.Nginx用C编写,不论是系统资源开销还是CPU使用效率都比Pe

centos 下编译安装mysql5.1与mysql5.5

mysql5.1.60编译安装 1.tar -zxvf mysql* 2../configure 之前要make clean ./configure --prefix=/home/shk/mysql-5.1.60 \ --enable-local-infile \ --with-unix-socket-path=/home/shk/mysql-5.1.60/var/mysql.sock \ --with-tcp-port=5506 \ --enable-thread-safe-client \

CentOS 6.8 编译安装MySQL5.5.32 (二 多实例)

MySQL多实例的配置 通过上文 CentOS 6.8 编译安装MySQL5.5.32 ,我们完成了编译安装,接下配置多实例 5,添加多实例目录 [[email protected] application]# mkdir -p /data/{3306,3307}/data [[email protected] application]# tree  /data/ /data/ ├── 3306    │   └── data    └── 3307        └── data, 6,上传多

开发人员学Linux(6):CentOS7编译安装MySQL5.17.8多实例及主从复制

1.前言上一篇讲述了如何在CentOS7下编译安装Nginx-1.12.0并如何配置反向代理,本篇将讲述如何编译安装MySQL5.7.18并配置多实例.2.准备2.1下载MySQL5.7.18源码注意最新版本的MySQL需要Boost才能编译安装,在MySQL提供的下载中有不带boost的源码,还有带boost的源码,如果下载不带boost的源码还需要再去下载boost源码,为省事起见,建议下载带boost的源码,下载地址:https://cdn.mysql.com//Downloads/MyS

centos6.4下编译安装MySQL-5.5.33

若想在6.4版本下的centos编译安装MySQL必须使用新的编译器cmake. 1)安装cmake 直接yum安装 2)编译安装参数 使用cmake编译安装mysql-5.5.33,选项的方式有所改变: ./configure                cmake .            编译   ./configure –help         cmake . -LH or ccmake .   获取帮助 指定安装文件的安装路径时常用的选项:    -DCMAKE_INSTALL_P

centos6.5编译安装mysql5.6.20

一.   准备工作 1     yum安装各个依赖包 [[email protected] ~]# yum –y install gcc gcc-devel gcc-c++ gcc-c++-devel  zlib*  ncurses-devel ncurses openssl openssl-devel bison bison-devel libaio [[email protected] ~]# yum –y install cmake 2.新建mysql组和用户 [[email protec

CentOS编译安装PHP开发环境

CentOS编译安装PHP开发环境 最近在安装服务器开发环境, 踩了不少坑, 这里总结下来. yum安装虽然简单, 却不灵活, 版本也比较老旧不合符设计中的选型, 因此只使用yum安装一些依赖库, 目标软件采用编译安装. 目录 安装PHP 安装PHP扩展 安装Phalcon框架 安装MySQL 安装MongoDB 安装Redis 安装PHP yum安装依赖库 yum install -y make cmake gcc gcc-c++ autoconf automake libpng-devel

Centos成功安装mysql-5.5.37

摘自http://www.2cto.com/os/201404/296364.html(原文请关注) 这几天在centos下装mysql,这里记录一下安装的过程,方便以后查阅 Mysql5.5.37安装需要cmake,5.6版本开始都需要cmake来编译,5.5以后的版本应该也要装这个. 安装cmake [plain] view plaincopyprint?01.[[email protected] ~]# wget http://www.cmake.org/files/v2.8/cmake-

centos6.6下编译安装mysql5.6之后启动失败:Starting MySQL... ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).

今天在编译安装mysql5.6时候出现Starting MySQL... ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).,当时就心碎了,之前安装时候好好的,在网上搜索帮助方法,可是没有和我一样的,有的说我没有给mysqld赋权限,可是我赋予他权限了,试了一堆方法,最后心灰意冷,准备删除mysql重新安装,就在我执行:yum remove mysql mysql