缺点:后期升级不方便,生产中建议RPM包方式安装

CentOS7默认安装了和MySQL有兼容性的MariaDB数据库,在我们安装MySQL5.7之前为了避免发生冲突首先删除MariaDB。

# rpm -qa | grep maria

# yum remove mariadb-libs -y

一、基于官方源码包安装

下载 mysql-5.7.22.tar.gz

安装cmake

# yum -y install cmake

# tar -zxvf mysql-5.7.22.tar.gz -C /usr/src

# cd /usr/src/mysql-5.7.22

# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/var/lib/mysql -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DENABLED_LOCAL_INFILE=1 -DWITH_EXTRA_CHARSETS=all -DMYSQL_USER=mysql

-- Running cmake version 2.8.11
-- Configuring with MAX_INDEXES = 64U
-- CMAKE_GENERATOR: Unix Makefiles
-- SIZEOF_VOIDP 8
-- MySQL 5.7.22
-- Packaging as: mysql-5.7.22-Linux-x86_64
-- Downloading boost_1_59_0.tar.gz to /usr/local/boost
-- [download 100% complete]
-- Download failed, error: 35;"SSL connect error"
CMake Error at cmake/boost.cmake:194 (MESSAGE):
  You can try downloading
  http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
  manually using curl/wget or a similar tool
Call Stack (most recent call first):
  CMakeLists.txt:506 (INCLUDE)

-- Configuring incomplete, errors occurred!

解决:下载boost_1_59_0.tar.gz,放在/usr/local/boost下

# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/var/lib/mysql -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DENABLED_LOCAL_INFILE=1 -DWITH_EXTRA_CHARSETS=all -DMYSQL_USER=mysql -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost

...

-- Check size of wint_t
-- Check size of wint_t - done
-- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:64 (MESSAGE):
  Curses library not found.  Please install appropriate package,

remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
  cmake/readline.cmake:107 (FIND_CURSES)
  cmake/readline.cmake:197 (MYSQL_USE_BUNDLED_EDITLINE)
  CMakeLists.txt:534 (MYSQL_CHECK_EDITLINE)

-- Configuring incomplete, errors occurred!

解决:

#yum -y install ncurses-devel

# rm -rf /usr/src/mysql-5.7.22/CMakeCache.txt

# gmake

# make install

安装之后的一些配置:

# cd /usr/local/mysql/support-files/
]# ll mysql.server
-rwxr-xr-x 1 root root 10569 Apr 20 11:11 mysql.server
# cp mysql.server /etc/init.d/mysql

# cd /var/lib/
# mkdir mysql
# chown mysql. mysql
# vi /etc/my.cnf

[mysqld]
basedir = /usr/local/mysql
datadir = /var/lib/mysql
port = 3306
socket = /tmp/mysqld.sock

mysql_install_db 被废弃了,取而代之的是 mysqld –initialize

# /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --initialize  --datadir=/var/lib/mysql --basedir=/usr/local/mysql --user=mysql
2018-04-20T07:49:28.669315Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-04-20T07:49:29.022395Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-04-20T07:49:29.090056Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-04-20T07:49:29.151786Z 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: 5ae072ef-446f-11e8-aa2d-0050568810c7.
2018-04-20T07:49:29.153819Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-04-20T07:49:29.155286Z 1 [Note] A temporary password is generated for root@localhost: ;1ruP:p6R8te
# ll /var/lib/mysql/
总用量 110628
-rw-r----- 1 mysql mysql       56 4月  20 15:49 auto.cnf
-rw-r----- 1 mysql mysql      417 4月  20 15:49 ib_buffer_pool
-rw-r----- 1 mysql mysql 12582912 4月  20 15:49 ibdata1
-rw-r----- 1 mysql mysql 50331648 4月  20 15:49 ib_logfile0
-rw-r----- 1 mysql mysql 50331648 4月  20 15:49 ib_logfile1
drwxr-x--- 2 mysql mysql     4096 4月  20 15:49 mysql
drwxr-x--- 2 mysql mysql     8192 4月  20 15:49 performance_schema
drwxr-x--- 2 mysql mysql     8192 4月  20 15:49 sys

# systemctl start mysql
# ps -ef|grep mysql

# vi ~/.bash_profile

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin

# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

配置文件中添加如下一行,跳过密码验证

# cat /etc/my.cnf
[mysqld]

skip-grant_tables

重启MySQL

# systemctl restart mysql

# mysql

mysql> update mysql.user set authentication_string=password('oracle') where user='root' ;

再次重启MySQL

# systemctl restart mysql

# mysql

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql> set password=password('123456');

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+

二、基于官方源代码RMP构建自定义MySQLRPM(一般用于企业内部开发,生产中还是MySQL包的方式安装)

创建一个普通用户,用于构建自定义的RPM包

# useradd tubeliu
# cp mysql-community-5.7.22-1.el7.src.rpm /home/tubeliu/
# chown tubeliu.tubeliu /home/tubeliu/ -R
# yum list | grep rpm-build
      
# yum -y install rpm-build

# su - tubeliu
 ls
mysql-community-5.7.22-1.el7.src.rpm
$ rpmbuild ~
错误:文件 /home/tubeliu 不是常规文件。
$ ls
mysql-community-5.7.22-1.el7.src.rpm  rpmbuild
$ cd rpmbuild/
$ ls
BUILD  BUILDROOT  RPMS  SOURCES  SPECS  SRPMS
$ cd ..
$ ls
mysql-community-5.7.22-1.el7.src.rpm  rpmbuild
$ rpm -ivh mysql-community-5.7.22-1.el7.src.rpm
正在升级/安装...
   1:mysql-community-5.7.22-1.el7     ################################# [100%]
$ cd rpmbuild/
$ ls
BUILD  BUILDROOT  RPMS  SOURCES  SPECS  SRPMS
$ ls -R
.:
BUILD  BUILDROOT  RPMS  SOURCES  SPECS  SRPMS

./BUILD:

./BUILDROOT:

./RPMS:

./SOURCES:
boost_1_59_0.tar.bz2  filter-requires.sh   mysql-5.7.22.tar.gz
filter-provides.sh    mysql-5.6.37.tar.gz

./SPECS:
mysql.spec

./SRPMS:
$ cd SPECS/
$ vi mysql.spec
$ rpmbuild -bb mysql.spec

在CentOS7上安装MySQL5.7-源码包方式的更多相关文章

  1. linux(centos6.5 i386)安装mysql5.6源码包

    在开始安装前,先说明一下mysql-5.6.4与较低的版本在安装上的区别,从mysql-5.5起,mysql源码安装开始使用cmake了,因此当我们配置安装目录./configure --perfix ...

  2. 在CentOS7上安装MySQL5.7-YUM源方式

    获取RPM包 # wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm 列出RPM包里都有哪些文件 # ...

  3. 在CentOS 7上安装Python3.5源码包

    最近开始系统学习Python 3.5,发现CentOS 7系统自带的python版本是Python 2.7.现在要使用Python 3.5该怎么办?方法大体跟安装其他程序一样.以下为详细经过: 1.事 ...

  4. 在 CentOS7 上安装 MySQL5.7

    在 CentOS7 上安装 MySQL5.7 1 通过 SecureCRT 连接到阿里云 CentOS7 服务器: 2 进入到目录 /usr/local/ 中: cd /usr/local/ 3 创建 ...

  5. MYSQL5.5源码包编译安装

    MYSQL5.5源码安装首先安装必要的库yum -y install gcc*###### 安装 MYSQL ######首先安装camke 一.支持YUM,则yum install -y cmake ...

  6. MYSQL5.7源码包编译安装

    Centos下用cmake编译安装MySQL 5.7安装依赖包yum -y install gcc gcc-c++ ncurses ncurses-devel cmake下载相应源码包cd /usr/ ...

  7. CentOS 安装MySQL5.7 源码方式安装

    MySQL rpm方式安装:https://www.cnblogs.com/deverz/p/9560403.html 1.卸载已经安装的MySQL yum list installed mysqlr ...

  8. CentOS7下源码包方式安装Erlang

    1.官网上下载源码包:OTP 19.1 Source File 2.把源码放在source目录中 , 解压 :tar -zxvf otp_src_19.1.tar.gz [或者 直接下载 rpm包 e ...

  9. linux 软件包安装方式选择、安装位置、源码包安装

    对外提供服务,比如apache,应使用源码包安装对内提供服务,比如gcc,只是我自己使用,使用rpm包安装 rpm包不需要指定安装位置,源码包的安装需要手动指定安装位置 rpm包默认安装位置/etc/ ...

随机推荐

  1. PID控制算法

    PID控制算法 四轴如何起飞的原理 四轴飞行器的螺旋桨与空气发生相对运动,产生了向上的升力,当升力大于四轴的重力时四轴就可以起飞了. 四轴飞行器飞行过程中如何保持水平: 我们先假设一种理想状况:四个电 ...

  2. weex 数据绑定,动态控制组件的显示内容及样式

    无论的原生开发还是weex开发,经常会需要我们对一些组件/控件动态赋值,在原生中,我们大家都知道,对控件setText就可以了,那么在weex中呢,我们需要怎么做呢,其实很简单,几行代码就可以搞定!首 ...

  3. 4类Storage方案(AS开发实战第四章学习笔记)

    4.1 共享参数SharedPreferences SharedPreferences按照key-value对的方式把数据保存在配置文件中,该配置文件符合XML规范,文件路径是/data/data/应 ...

  4. 使用@Value进行静态常量的值注入

    @Component public class ExpressConstant { public static String URL; @Value("${express.url}" ...

  5. Servlet映射规范和隐式映射

    问题描述: web.xml中配置了缺省路径"/"后,原先在webapp下的静态页面(html)无法通过URL访问了,为什么? 过程尝试: 1. 将html后缀改为.jsp后可以正常 ...

  6. 为订阅内虚拟机批量安装并配置 Microsoft Anti-Malware 扩展

    本文提供了对订阅内的 Windows 经典部署虚拟机和资源管理器部署虚拟机执行批量安装并配置 Microsoft Anti-Malware 扩展的 PowerShell 脚本. 关于安装 Window ...

  7. 找工作笔试面试那些事儿(13)---操作系统常考知识点总结 ZZ 【操作系统】

    http://blog.csdn.net/han_xiaoyang/article/details/11285485 上一节对数据库的知识做了一个小总结,实际找工作过程中,因为公司或单位侧重点不一样, ...

  8. asp.net的HTTP请求处理过程

    1.asp.net的HTTP请求处理过程 说明: (1).客户端浏览器向服务器发出一个http请求,此请求会被inetinfo.exe进程截获,然后转交给aspnet_isapi.dll进程,接着它又 ...

  9. [翻译] DZNSegmentedControl

    DZNSegmentedControl A drop-in replacement for UISegmentedControl for showing counts, to be used typi ...

  10. 沉淀再出发:mongodb的使用

    沉淀再出发:mongodb的使用 一.前言 这是一篇很早就想写却一直到了现在才写的文章.作为NoSQL(not only sql)中出色的一种数据库,MongoDB的作用是非常大的,这种文档型数据库, ...