缺点:后期升级不方便,生产中建议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. centos7上安装python3

    一.安装环境及版本 CentOS 6.5 Python 3.6.1 二.安装依赖包 1.安装静态库 # yum install -y openssl-static 注:如果不安装该静态库,会导致pyt ...

  2. Handlebars.js中集合(list)通过中括号的方式取值

    有这么一个需求,在一个table中,tr是通过each取值,取出的值要与table标题相对应,如何实现?例如: <table> <thead> <tr> {{#ea ...

  3. PHP-FPM详解

    目录 作用 安装 全局配置 配置进程池 参考Company开发环境 转发请求给PHP-FPM 思考 作用 PHP-FPM(PHP FastCGI Process Manager)意:PHP FastC ...

  4. 提升PHP速度

    PHP的优点之一是速度很快,对于一般的网站应用,可以说是已经足够了.不过如果站点的访问量很高.带宽窄或者其它的因素令服务器产生性能瓶颈的时候,你可能得想想其它的办法来进一步提高PHP的速度了.这篇文章 ...

  5. TCP/IP 协议图--计算机网络体系结构分层

    计算机网络体系结构分层   计算机网络体系结构分层 不难看出,TCP/IP 与 OSI 在分层模块上稍有区别.OSI 参考模型注重“通信协议必要的功能是什么”,而 TCP/IP 则更强调“在计算机上实 ...

  6. 四、C# 5.0 新特性——Async和Await使异步编程更简单

    一.引言 .NET 4.5 的推出,对于C#又有了新特性的增加--就是C#5.0中async和await两个关键字,这两个关键字简化了异步编程,之所以简化了,还是因为编译器给我们做了更多的工作,下面就 ...

  7. kali_metasploit问题

    出现类似提示: Failed to connect to the database: could not connect to server: Connection refused    Is the ...

  8. Python的getattr(),setattr(),delattr(),hasattr()及类内建__getattr__应用

    @Python的getattr(),setattr(),delattr(),hasattr() 先转一篇博文,参考.最后再给出一个例子 getattr()函数是Python自省的核心函数,具体使用大体 ...

  9. 死磕salt系列-salt 故障汇总

    这里将salt使用过程中遇到的所有的故障进行一个汇总. grains 匹配后多了一个列表 salt-master中配置jinja模板来匹配自定义的grins. vim /etc/salt/minion ...

  10. @property 装饰器

    property() 函数作用于新式类,返回属性值. class C(object): def __init__(self): self._x = None def getx(self): print ...