安装前工作:
1,从官方网址下载MySQL5.7.11源码包,大概49M
2,安装好cmake
3. yum -y install gcc gcc-c++ autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake libaio libaio-devel autoconf bzr bison libtool //这是个人在安装老版本使用的,相关依赖包
正式安装MySQL
1. 添加MySQL用户和所属组
groupadd mysql
useradd -r -g mysql mysql
2. 解压源码包
tar -zxvf mysql-5.7.11.tar.gz
3. 开始踩MySQL的坑
设置好make编译的目录
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ //MySQL安装文件目录
-DMYSQL_DATADIR=/mysql/data \ //MySQL数据文件目录
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ //sock文件目录
-DDEFAULT_CHARSET=utf8 \ //字符集设置
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=1
4. 进入到解压后的源码包中 cmake
[root@zhangMySQL5711 mysql-5.7.11]# cmake \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DMYSQL_DATADIR=/mysql/data \
> -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DEXTRA_CHARSETS=all \
> -DENABLED_LOCAL_INFILE=1
-- Running cmake version 2.8.12.2
-- Could NOT find Git (missing: GIT_EXECUTABLE)
-- Configuring with MAX_INDEXES = 64U
-- The C compiler identification is GNU 4.4.7
-- The CXX compiler identification is GNU 4.4.7
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for SHM_HUGETLB
-- Looking for SHM_HUGETLB - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void *
-- Check size of void * - done
-- SIZEOF_VOIDP 8
-- MySQL 5.7.11
-- Packaging as: mysql-5.7.11-Linux-x86_64
-- Looked for boost/version.hpp in and
-- BOOST_INCLUDE_DIR BOOST_INCLUDE_DIR-NOTFOUND
-- LOCAL_BOOST_DIR
-- LOCAL_BOOST_ZIP
-- Could not find (the correct version of) boost. //出现问题了
-- MySQL currently requires boost_1_59_0
CMake Error at cmake/boost.cmake:81 (MESSAGE):
You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST= //需要boost支持,这一点跟5.6版本的不一样
This CMake script will look for boost in . If it is not there,
it will download and unpack it (in that directory) for you.
If you are inside a firewall, you may need to use an http proxy:
export http_proxy=http://example.com:80
Call Stack (most recent call first):
cmake/boost.cmake:238 (COULD_NOT_FIND_BOOST)
CMakeLists.txt:443 (INCLUDE)
-- Configuring incomplete, errors occurred!
See also "/root/mysql-5.7.11/CMakeFiles/CMakeOutput.log".
重新按照要求加上boost选项,再次cmake:
[root@zhangMySQL5711 mysql-5.7.11]# cmake \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DMYSQL_DATADIR=/mysql/data \
> -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DEXTRA_CHARSETS=all \
> -DENABLED_LOCAL_INFILE=1 \
> -DDOWNLOAD_BOOST=1 \
> -DWITH_BOOST=/usr/local/boost
-- Running cmake version 2.8.12.2
-- Could NOT find Git (missing: GIT_EXECUTABLE)
-- Configuring with MAX_INDEXES = 64U
-- SIZEOF_VOIDP 8
-- MySQL 5.7.11
-- Packaging as: mysql-5.7.11-Linux-x86_64
-- Downloading boost_1_59_0.tar.gz to /usr/local/boost
-- [download 0% complete]
-- [download 1% complete]
-- [download 2% complete]
-- [download 3% complete]
-- [download 4% complete]
-- [download 5% complete]
-- [download 6% complete]
-- [download 7% complete]
-- Download failed, error: 28;"Timeout was reached" //实在是受不了这蜗牛的速度,大概30Kb/s 所以下载失败
CMake Error at cmake/boost.cmake:187 (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, or increase the value of
DOWNLOAD_BOOST_TIMEOUT (which is now 600 seconds)
Call Stack (most recent call first):
CMakeLists.txt:443 (INCLUDE)
下载好boost文件,
[root@zhangMySQL5711 boost]# pwd //目录要和cmake 定义的一致
/usr/local/boost
[root@zhangMySQL5711 boost]# ll
total 81760
drwx------ 8 zabbix 20 4096 Aug 12 2015 boost_1_59_0
-rw-r--r-- 1 root root 83709983 Feb 24 16:42 boost_1_59_0.tar.gz //下载好的,解压即可
重新定义cmake
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/mysql/data \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=1 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/boost/boost_1_59_0
[root@zhangMySQL5711 mysql-5.7.11]# cmake \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DMYSQL_DATADIR=/mysql/data \
> -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci \
> -DEXTRA_CHARSETS=all \
> -DENABLED_LOCAL_INFILE=1 \
> -DDOWNLOAD_BOOST=1 \
> -DWITH_BOOST=/usr/local/boost/boost_1_59_0
-- Running cmake version 2.8.12.2
-- Could NOT find Git (missing: GIT_EXECUTABLE)
-- Configuring with MAX_INDEXES = 64U
-- The C compiler identification is GNU 4.4.7
-- The CXX compiler identification is GNU 4.4.7
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
..... //篇幅太大了,截取开头和结尾
-- Performing Test HAVE_NO_UNUSED_TYPEDEFS - Success
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl;aio
-- INSTALL mysqlclient.pc lib/pkgconfig
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;HAVE_CONFIG_H
-- CMAKE_C_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement
-- CMAKE_CXX_FLAGS: -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter
-- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /root/mysql-5.7.11
到这里cmake完成,比较顺利
5. make 操作
[root@zhangMySQL5711 mysql-5.7.11]# make //漫长的过程 主要看机器的配置,我的虚拟机给了1300M,所以大概用了25分钟
Scanning dependencies of target INFO_BIN
[ 0%] Built target INFO_BIN
Scanning dependencies of target INFO_SRC
[ 0%] Built target INFO_SRC
Scanning dependencies of target abi_check
[ 0%] Built target abi_check
Scanning dependencies of target zlib
[ 0%] Building C object zlib/CMakeFiles/zlib.dir/adler32.c.o
[ 0%] Building C object zlib/CMakeFiles/zlib.dir/compress.c.o
[ 0%] Building C object zlib/CMakeFiles/zlib.dir/crc32.c.o
[ 0%] Building C object zlib/CMakeFiles/zlib.dir/deflate.c.o
[ 0%] Building C object zlib/CMakeFiles/zlib.dir/gzio.c.o
..... ..... .....
Linking CXX executable mysql_embedded
[100%] Built target mysql_embedded
Scanning dependencies of target mysqltest_embedded
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.o
Linking CXX executable mysqltest_embedded
[100%] Built target mysqltest_embedded
Scanning dependencies of target my_safe_process
[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
Linking CXX executable my_safe_process
[100%] Built target my_safe_process
[root@zhangMySQL5711 mysql-5.7.11]#
注意:
mysql 5.6.19 版本编译后的文件包约2G // 笔者一直使用的是5.6.19及以上版本
MySQL5.7.11 编译安装对磁盘的需求也比以往的版本多很多,make之后的 mysql-5.7.11 文件夹约4.8G
开始编译前:
[root@zhangMySQL5711 boost]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
11G 4.3G 5.3G 45% /
tmpfs 634M 0 634M 0% /dev/shm
/dev/sda1 477M 112M 340M 25% /boot
编译完成后:
[root@zhangMySQL5711 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
11G 9.1G 427M 96% /
tmpfs 634M 0 634M 0% /dev/shm
/dev/sda1 477M 112M 340M 25% /boot
/dev/sdb1 5.8G 12M 5.5G 1% /mysql
此时如果执行make install 会因为磁盘不足,导致缺失重要的文件,笔者,尝试过几次,均失败。 最后的报错如下:
-- Installing: /usr/local/mysql/bin/mysql_embedded
CMake Error at libmysqld/examples/cmake_install.cmake:42 (FILE):
file INSTALL cannot copy file
"/root/mysql-5.7.11/libmysqld/examples/mysql_embedded" to
"/usr/local/mysql/bin/mysql_embedded".
Call Stack (most recent call first):
cmake_install.cmake:116 (INCLUDE)
make: *** [install] Error 1
[root@zhangMySQL5711 mysql-5.7.11]#
并且5.7.11的安装文件也比以往略大
5.6.19 ---->1.1G
5.7.11 ---->1.9G
所以建议大家尽量给多一点空间
6. make install 安装:
[root@zhangMySQL5711 mysql-5.7.11]# make install
........
-- Installing: /usr/local/mysql/mysql-test/./lib/mtr_misc.pl
-- Up-to-date: /usr/local/mysql/mysql-test/mtr
-- Up-to-date: /usr/local/mysql/mysql-test/mysql-test-run
-- Installing: /usr/local/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Up-to-date: /usr/local/mysql/mysql-test/lib/My/SafeProcess/my_safe_process
-- Installing: /usr/local/mysql/mysql-test/lib/My/SafeProcess/Base.pm
-- Installing: /usr/local/mysql/support-files/my-default.cnf
-- Installing: /usr/local/mysql/support-files/mysqld_multi.server
-- Installing: /usr/local/mysql/support-files/mysql-log-rotate
-- Installing: /usr/local/mysql/support-files/magic
-- Installing: /usr/local/mysql/share/aclocal/mysql.m4
-- Installing: /usr/local/mysql/support-files/mysql.server
[root@zhangMySQL5711 mysql-5.7.11]#
7. 初始化MySQL
[root@zhangMySQL5711 bin]# ./mysqld --initialize --user=mysql --datadir=/mysql/data --basedir=/usr/local/mysql --socket=/tmp/mysql.sock //在MySQL 5.7.6版本以前是 bin/mysql_install_db --user
2016-02-25T04:36:27.941245Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-02-25T04:36:29.363359Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-02-25T04:36:29.529261Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-02-25T04:36:29.615486Z 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: 56a9ad19-db79-11e5-bc10-080027207e2e.
2016-02-25T04:36:29.635578Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-02-25T04:36:29.645190Z 1 [Note] A temporary password is generated for root@localhost: oej<ibtee2r?
[root@zhangMySQL5711 bin]#
8. 添加MySQL服务
[root@zhangMySQL5711 support-files]# cp mysql.server /etc/init.d/mysql
9. 编辑my.cnf文件
[root@zhangMySQL5711 support-files]# vi /etc/my.cnf //添加下面的,这里为了简洁,省去其他的,都是按照默认的
[mysqld]
port=3306
basedir=/usr/local/mysql
datadir=/mysql/data
socket=/tmp/mysql.sock
10. 重启MySQL
[root@zhangMySQL5711 support-files]# /etc/init.d/mysql start
Starting MySQL.. SUCCESS!
11. 登录MySQL
[root@zhangMySQL5711 support-files]# cd ../bin/
[root@zhangMySQL5711 bin]# ./mysql -uroot -p //第一次登录MySQL,密码文件在,也可以从make install 最后的一行看到密码
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.11
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>
12. 修改root密码
mysql> set password=password('zhangmysql');
Query OK, 0 rows affected, 1 warning (0.00 sec) //查看warning 提示
mysql> show warnings;
+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message //下面提示我那种方法以后将会被遗弃 |
+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 1287 | 'SET PASSWORD = PASSWORD('')' is deprecated and will be removed in a future release. Please use SET PASSWORD = '' instead |
+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
结束!
发表评论
-
mysql5.7开启主从同步
2016-10-22 23:06 659在同一台服务器的2个实例(3355,3366)进行测试 ... -
MySQL5.7的备份与恢复简介和使用mysqldump备份MySQL数据库
2016-10-20 22:31 5879一、备份的类型和其他说明: 1.1 按备份时服务器是否继续 ... -
mysql5.7创建用户授权-删除用户撤销授权
2016-10-16 20:39 4731一, 创建用户: 命令:CREATE US ... -
mysql5.7多实例重置密码
2016-10-15 23:41 1316mysql5.7非多实例重置密码 杀掉mysql后执行li ... -
mysql5.7多实例
2016-10-13 22:42 984启动端口号为3355和3366的二个实例。创建文件夹 ...
相关推荐
- 选择 Linux-Generic 下的 `mysql-cluster-advanced-7.3.8-linux-glibc2.5-x86_64.tar.gz` 这个安装包进行下载。 #### 三、环境清理 在所有服务器上执行以下操作以确保没有之前的 MySQL 安装残留: 1. **清除 ...
### CentOS编译安装MYSQL5.6.17 #### 知识点概览 - **环境准备**:包括操作系统版本的选择、依赖包的安装等。 - **编译工具的安装**:如`cmake`的下载与安装。 - **MySQL源码包的获取与解压**。 - **配置与编译...
在本文中,我们将深入探讨如何在CentOS 6.6上编译安装MySQL 5.6,并配置主从复制,以实现数据的安全备份和负载均衡。 **一、MySQL编译安装** 1. **环境准备**:确保你的CentOS系统已经更新到最新,且安装了必要的...
安装完成后,用户可以使用`yum`或`dnf`(Dandified Yum,CentOS 7中默认的包管理器)来安装额外的软件和服务,例如Web服务器(Apache或Nginx)、数据库(MySQL或PostgreSQL)、开发工具等。此外,由于CentOS 7基于...
centos7编译安装mysql
MySQL 版本:mysql-5.6.10 MySQL 安装目录:/usr/local/mysql MySQL 数据库存放目录:/data/mysql 准备篇: 一、配置好IP、DNS 、网关,确保使用远程连接工具能够连接服务器,服务器yum 命令可 以正常使用
接下来,运行`yum install mysql-community-server`命令来安装MySQL服务器。这个命令会自动处理依赖关系,下载并安装所有必要的组件。 安装完成后,你需要启动MySQL服务,使用`service mysqld start`命令。此时,...
tar zxvf mysql-5.6.19.tar.gz #解压 cd mysql-5.6.19 #进入目录 cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc #配置 make #编译 make install #安装 rm -...
CentOS是Community ENTerprise Operating System的缩写,是一个基于Red Hat Enterprise Linux(RHEL)源代码重新编译的开源操作系统。它旨在提供一个免费、稳定、高可靠性的企业级计算平台。 【描述】中提到的...
同时,安装一些必需的依赖包,例如gcc、ncurses-devel等,用于编译MySQL: ``` yum install gcc ncurses-devel -y ``` 二、下载MySQL安装包 "install_mysql"这个压缩包文件包含了MySQL 5.6的安装源代码或二进制文件...
在开始安装MySQL之前,需要先安装一些必要的依赖包,如gcc、ncurses-devel等,这些是编译MySQL时必需的。你可以通过运行以下命令来安装它们: ``` yum install -y gcc ncurses-devel ``` 2. **下载MySQL...
在Linux系统中,尤其是像CentOS这样的企业级操作系统上,手动编译安装软件是一个常见的实践,特别是对于老旧版本如CentOS 6.4,因为它的默认仓库可能不包含最新版本的软件,例如MySQL 5.7.9。下面将详细介绍在CentOS...
[root@zheng2 mysql-5.5.30]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DSYSCONFDIR=/etc \ -DMYSQL_USER=mysql \ ...
在本节"Dubbo视频教程--第46节:MySQL源码编译安装(CentOS-6.rar"中,我们将深入探讨如何在CentOS 6操作系统上通过源代码编译安装MySQL 5.6版本,同时也会涉及到这个过程与Dubbo框架的关联。MySQL是一个广泛使用的...
### CentOS 6.5 下编译安装 LAMP 环境详细步骤 LAMP 是一套常用的网站服务器软件组合,由 Linux、Apache、MySQL 和 PHP 四部分组成。本文将详细介绍如何在 CentOS 6.5 系统上从源码编译安装 LAMP。 #### 一、MySQL...
在CentOS操作系统中,安装MySQL服务器需要经过一系列的步骤,包括下载、编译、安装、初始化数据库、注册服务、启动服务等。本文将详细介绍CentOS下MySQL的安装过程。 下载MySQL源代码 首先,需要下载MySQL的源代码...
在本文中,我们将深入探讨如何在CentOS 7.2操作系统上使用Yum工具编译安装MySQL 5.6。这个过程对于系统管理员来说非常重要,因为它允许他们为自己的服务器或开发环境设置一个稳定且可定制的数据库服务。 首先,我们...
同时,你需要安装一些编译MySQL所需的依赖库,包括: 1. 开发工具集:`sudo yum groupinstall "Development Tools"` 2. OpenSSL:用于提供安全连接,`sudo yum install openssl-devel` 3. zlib:数据压缩库,`sudo ...