您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關(guān)CentOS6.5如何編譯安裝最新MySQL 5.7.11的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。
安裝前工作:
1,從官方網(wǎng)址下載MySQL5.7.11源碼包,大概49M
2,安裝好CentOS6.5 64位操作系統(tǒng)。建議update操作系統(tǒng),以便是此版本最新的
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 //這是個(gè)人在安裝老版本使用的,相關(guān)依賴包
正式安裝MySQL
1. 添加MySQL用戶和所屬組
groupadd mysql
useradd -r -g mysql mysql
2. 解壓源碼包
tar -zxvf mysql-5.7.11.tar.gz
3. 開始踩MySQL的坑
設(shè)置好make編譯的目錄
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ //MySQL安裝文件目錄
-DMYSQL_DATADIR=/mysql/data \ //MySQL數(shù)據(jù)文件目錄
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ //sock文件目錄
-DDEFAULT_CHARSET=utf8 \ //字符集設(shè)置
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=1
4. 進(jìn)入到解壓后的源碼包中 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. //出現(xiàn)問題了
-- 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支持,這一點(diǎn)跟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選項(xiàng),再次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" //實(shí)在是受不了這蝸牛的速度,大概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 //建議復(fù)制鏈接,直接瀏覽器上,或者迅雷上下載,速度超快
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
..... //篇幅太大了,截取開頭和結(jié)尾
-- 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 //漫長的過程 主要看機(jī)器的配置,我的虛擬機(jī)給了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 編譯安裝對(duì)磁盤的需求也比以往的版本多很多,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
此時(shí)如果執(zhí)行make install 會(huì)因?yàn)榇疟P不足,導(dǎo)致缺失重要的文件,筆者,嘗試過幾次,均失敗。 最后的報(bào)錯(cuò)如下:
-- 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
所以建議大家盡量給多一點(diǎn)空間
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服務(wù)
[root@zhangMySQL5711 support-files]# cp mysql.server /etc/init.d/mysql
9. 編輯my.cnf文件
[root@zhangMySQL5711 support-files]# vi /etc/my.cnf //添加下面的,這里為了簡(jiǎn)潔,省去其他的,都是按照默認(rèn)的
[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 //下面提示我那種方法以后將會(huì)被遺棄 |
+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| 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)
感謝各位的閱讀!關(guān)于“CentOS6.5如何編譯安裝最新MySQL 5.7.11”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。