Centos 7.2 编译安装 MySQL 5.7.14

一、环境准备

1、查看系统版本

[[email protected] ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[[email protected] ~]# uname -r
3.10.0-327.28.2.el7.x86_64

2、卸载系统自带的mysql/mariadb数据库及boost旧版本

rpm -qa | grep mysql
rpm -qa | grep mariadb
rpm -e --nodeps boost-system-1.53.0-25.el7.x86_64
rpm -e --nodeps boost-thread-1.53.0-25.el7.x86_64
rpm -e mariadb-libs-5.5.47-1.el7_2.x86_64
rpm -e --nodeps mariadb-libs-5.5.47-1.el7_2.x86_64
boost官网http://www.boost.org/ ,yum -y install boost boost-devel boost-doc安装的是boost1.53版本

3、准备安装文件

[[email protected] mysql]# ll
total 131096
drwx------ 10  501 games     4096 Aug 17 15:02 boost_1_59_0
-rw-r--r--  1 root root  83709983 Aug 13  2015 boost_1_59_0.tar.gz
drwxr-xr-x 37 7161 31415     4096 Aug 17 15:48 mysql-5.7.14
-rw-r--r--  1 root root  50517329 Aug 17 14:38 mysql-5.7.14.tar.gz

说明:mysql5.7系列指定boost版本为boost_1_59_0。

资源下载地址:

wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
wget ftp://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.7/mysql-5.7.14.tar.gz

4、依赖包安装

yum -y install make gcc-c++ cmake bison-devel ncurses-devel libaio libaio-devel perl-Data-Dumper net-tools

二、安装boost/mysql

1、安装boost

1 tar xvf boost_1_59_0
2 cd boost_1_59_0
3 ./bootstrap.sh --with-libraries=system,filesystem,log,thread --with-toolset=gcc
4 ./b2 toolset=gcc cxxflags="-std=c++11"
5 ./b2 install --prefix=/usr/local/boost

#备注:上面红色字体的内容,参考如下配置;上面绿色字体内容代表使用c++11标准,编译的库要使用统一标准。不使用,去掉绿色字体内容。

  

 1 Component configuration:
 2     - atomic                   : not building
 3     - chrono                   : not building
 4     - context                  : not building
 5     - coroutine                : not building
 6     - date_time                : not building
 7     - exception                : not building
 8     - filesystem               : building
 9     - graph                    : not building
10     - graph_parallel           : not building
11     - iostreams                : not building
12     - locale                   : not building
13     - log                      : building
14     - math                     : not building
15     - mpi                      : not building
16     - program_options          : not building
17     - python                   : not building
18     - random                   : not building
19     - regex                    : not building
20     - serialization            : not building
21     - signals                  : not building
22     - system                   : building
23     - test                     : not building
24     - thread                   : building
25     - timer                    : not building
26     - wave                     : not building

#默认安装在/usr/local/lib目录下;头文件在/usr/local/include/boost目录下;install后面可以加参数 --prefix=/usr 来设置安装路径

#如果提示boost版本不对应则卸载boost安装对应版本boost

2、编译安装mysql 

 1 tar xvf mysql-5.7.14.tar.gz
 2 cd mysql-5.7.14
 3
 4 cmake  5 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \     #MySQL的安装目录
 6 -DMYSQL_DATADIR=/usr/local/mysql/data \      #MySQL的数据目录
 7 -DSYSCONFDIR=/etc \                  #my.cnf路径
 8 -DWITH_MYISAM_STORAGE_ENGINE=1 \          #启用MySQL的myisam引擎
 9 -DWITH_INNOBASE_STORAGE_ENGINE=1 \         #启用MySQL的innobase引擎
10 -DWITH_MEMORY_STORAGE_ENGINE=1 \                #启用MySQL的memory引擎
11 -DWITH_READLINE=1 \                             #启用readline库支持(提供可编辑的命令行)
12 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \   #连接数据库socket路径
13 -DMYSQL_TCP_PORT=3306 \                         #MySQL端口
14 -DENABLED_LOCAL_INFILE=1 \                      #允许从本地导入数据
15 -DWITH_PARTITION_STORAGE_ENGINE=1 \             #安装支持数据库分区
16 -DEXTRA_CHARSETS=all \                          #安装所有的字符集
17 -DDEFAULT_CHARSET=utf8 \                        #设置默认字符集为utf-8
18 -DDEFAULT_COLLATION=utf8_general_ci \           #设定默认排序规则(utf8_general_ci快速/utf8_unicode_ci准确)
19 -DDOWNLOAD_BOOST=1 \                            #下载boost
20 -DWITH_BOOST=/usr/local//boost                  #boost的安装目录
21
22 make && make install

三、配置mysql

1、创建用户,初始化数据库 

groupadd mysql
useradd -g mysql -s /sbin/nologin mysql

2、授权mysql数据库目录

chown -R mysql:mysql /usr/local/mysql

3、初始化mysql数据库

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

4、拷贝配置文件,修改配置文件

 1 cp support-files/my-default.cnf /etc/my.cnf
 2 [[email protected] ~]# cat /etc/my.cnf
 3 # For advice on how to change settings please see
 4 # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
 5 # *** DO NOT EDIT THIS FILE. It‘s a template which will be copied to the
 6 # *** default location during install, and will be replaced if you
 7 # *** upgrade to a newer version of MySQL.
 8 [mysqld]
 9 # Remove leading # and set to the amount of RAM for the most important data
10 # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
11 # innodb_buffer_pool_size = 128M
12 character_set_server=utf8
13 init_connect=‘SET NAMES utf8‘
14 #skip-grant-tables
15 # Remove leading # to turn on a very important data integrity option: logging
16 # changes to the binary log between backups.
17 # log_bin
18 # These are commonly set, remove the # and set as required.
19 # basedir = .....
20 #datadir =  /usr/local/mysql/data
21 # port = .....
22 # server_id = .....
23 # socket = .....
24 # Remove leading # to set options mainly useful for reporting servers.
25 # The server defaults are faster for transactions and fast SELECTs.
26 # Adjust sizes as needed, experiment to find the optimal values.
27 # join_buffer_size = 128M
28 # sort_buffer_size = 2M
29 # read_rnd_buffer_size = 2M
30 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
31 [client]
32 default-character-set=utf8

5、拷贝启动文件,并授权

1、cp support-files/mysql.server /etc/init.d/mysqld
2、chmod 755 /etc/init.d/mysqld

6 、启动数据库

  

/etc/init.d/mysqld start

三、更改初始化生成的数据库密码

注:由于5.7版本会初始化设置密码,需要自己修改,跟之前的数据库版本更改方式不一样。

完整的更改MySQL密码的方式如下:

  • vim /etc/my.cnf 加入skip-grant-tables,免密码登录数据库

注:我这里注释掉是改完之后再演示的。

  • 重启MySQL数据库
[[email protected] ~]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS! 
  • 登录数据,修改密码即可,注5.7的password字段改为authentication_string
MySQL
update mysql.user set authentication_string=password(‘root‘) where user=‘root‘ ;
  • 更改完后,注释掉my.cnf里面的skip-grant-tables 这一行,重启MySQL登录验证即可,然后就可以登录数据库进行一些简单的操作了。
[[email protected] ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.14 Source distribution
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| engine_cost               |
| event                     |
| func                      |
| general_log               |
| gtid_executed             |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| innodb_index_stats        |
| innodb_table_stats        |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| server_cost               |
| servers                   |
| slave_master_info         |
| slave_relay_log_info      |
| slave_worker_info         |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
31 rows in set (0.00 sec)

参考资料:

http://www.bkjia.com/Linuxjc/1096474.html

http://blog.csdn.net/langzi7758521/article/details/51435985

http://www.07net01.com/storage_networking/2016/01/1141976.html

时间: 2024-12-18 16:47:31

Centos 7.2 编译安装 MySQL 5.7.14的相关文章

CentOS 6.4 编译安装Mysql 5.6.14

概述: CentOS 6.4下通过yum安装的MySQL是5.1版的,比较老,所以就想通过源代码安装高版本的5.6.14. 正文: 一:卸载旧版本 使用下面的命令检查是否安装有MySQL Server rpm -qa | grep mysql 有的话通过下面的命令来卸载掉 rpm -e mysql //普通删除模式 rpm -e --nodeps mysql // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除 二:安装MySQL 安装编译代码需要的包

CentOS源码编译安装MySQL 5.5.15

CentOS源码编译安装MySQL 5.5.15 文章目录 [隐藏] 安装编译工具 下载源码 安装cmake和bison 编译安装MySQL 一些相关设置 安装编译工具 yum install gcc gcc-c++ yum install ncurses-devel 下载源码 mkdir -p /tmp cd /tmp wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.15.tar.gz/from/http://mysql.

CentOS 6.4下编译安装MySQL 5.6.14

CentOS 6.4下编译安装MySQL 5.6.14 概述: CentOS 6.4下通过yum安装的MySQL是5.1版的,比较老,所以就想通过源代码安装高版本的5.6.14. 正文: 一:卸载旧版本 使用下面的命令检查是否安装有MySQL Server rpm -qa | grep mysql 有的话通过下面的命令来卸载掉 rpm -e mysql //普通删除模式 rpm -e --nodeps mysql // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对

Centos 5.5 编译安装mysql 5.5.9

下载mysql wget  http://mysql.mirrors.pair.com/Downloads/MySQL-5.5/mysql-5.5.9.tar.gz 创建mysql用户 [[email protected] opt]# useradd -g mysql mysql3307 -s /bin/nologin -d /usr/local/mysql3307 创建数据目录 [[email protected] opt]# mkdir /mysqldata/dirdata/mysql330

LNMP搭建01 -- 编译安装MySQL 5.6.14 和 LNMP相关的区别

[编译安装MySQL 5.6.14] [http://www.cnblogs.com/xiongpq/p/3384681.html ]  [mysql-5.6.14.tar.gz 下载] http://pan.baidu.com/s/1jGIffFo   一:卸载旧版本 使用下面的命令检查是否安装有MySQL,若是初次安装直接跳过. rpm -qa | grep mysql 有的话通过下面的命令来卸载掉 其实很简单,直接删除编译后的安装目录,例如:/usr/local/mysql 即可. rpm

CentOS Linux下编译安装MySQL

本文参考张宴的Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器(第6版)[原创]完成.所有操作命令都在CentOS 6.4 64位操作系统下实践成功. 1.移除CentOS自带的mysql yum remove mysql mysql-server compat-mysql51 rpm -e --nodeps mysql-libs-5.1.* 2.安装编译依赖包 yum -y install cmake yum -y install bis

centos 7.0 编译 安装mysql 5.6.22 过程 未完成~~持续

mysql 下载目录/usr/local/srcmysql 解压目录 /usr/local/bin/mysql GitHub https://github.com/mysql/mysql-server mysql官网的安装说明http://dev.mysql.com/doc/refman/5.6/en/source-installation.html 安装mysql必须的要求 CMake make3.75以上 GCC 4.2.1以上 PerlCurses ncurses-devel 最新3.1.

CentOS 6下编译安装MySQL 5.6

一:卸载旧版本 使用下面的命令检查是否安装有MySQL Server rpm -qa | grep mysql 有的话通过下面的命令来卸载掉 rpm -e mysql //普通删除模式 rpm -e --nodeps mysql // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除 二:安装MySQL 安装编译代码需要的包 yum -y install make gcc-c++ cmake bison-devel ncurses-devel 下载MyS

centos 6.5 编译安装 mysql 5.5.40

1.安装mysql依赖包 yum install zlib-devel openssl-devel gcc-c++gcc bison cmake ncurses-devel –y 2.建立mysql用户及组,建立mysql的存放数据的目录 groupadd -r mysql useradd -g mysql -r -s /sbin/nologin mysql mkdir –p /data/mysql chown –R mysql:mysql /data/mysql 3.安装编译mysql tar