缺点:后期升级不方便,生产中建议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. Android 简单图片浏览器 读取sdcard图片+形成缩略图+Gallery

    1.读取SD卡上面的图片信息 //想要的返回值所在的列 String[] projection = { MediaStore.Images.Thumbnails._ID}; //图片信息存储在 and ...

  2. JS Error 内置异常类型 处理异常 Throw语句

    Exceptional Exception Handling in JavaScript       MDN资料 Anything that can go wrong, will go wrong. ...

  3. 统计nginx日志

    .根据访问IP统计UV awk '{print $1}' access.log|sort | uniq -c |wc -l .统计访问URL统计PV awk '{print $7}' access.l ...

  4. Angular5中提取公共组件之radio list

    上一篇说到了Checkbox List的公共组件提取,现在说一下Radio List的公共组件提取. Radio List组件提取起来很方便,不想Checkbox那么复杂. radio-list.co ...

  5. ajax实现跨域提交

    因为现在一直用的mvc,所以就以mvc来说说ajax跨域提交. 首先说说跨域,简单说就是不同域名访问,比如在aaa.com访问bbb.com. 就拿招聘网站来说,分为两种用户,求职者和企业,求职者端是 ...

  6. [翻译] BBCyclingLabel

    BBCyclingLabel BBCyclingLabel is just like a UILabel but allows you to perform custom animations whe ...

  7. Java学习---InetAddress类的学习

    基础知识 1.InetAddress类 在网络API套接字,InetAddress类和它的子类型对象使用域名DNS系统,处理主机名到主机IPv4或IPv6地址的转换.如图1-1所示. 由于InetAd ...

  8. 沉淀,再出发:PHP的简单使用

    沉淀,再出发:PHP的简单使用 一.前言 关于PHP,笔者在本科的时候就听到了太多太多,可惜虽然看了很多的教材,听到了无数遍,也没有系统性的整理过和学习过这方面的知识,这点无论什么时候想起来都是一种遗 ...

  9. How to Remove A Service Entry From Win10 Service List

    Warning Please do this operation CAREFULLY, otherwise you may get something wrong with your system. ...

  10. August 02nd 2017 Week 31st Wednesday

    Love means never having to say you are sorry. 爱就是永远不必说对不起. If there is ture love, you will never do ...