[MYSQL] mysql source code install(5.7.15)

tolilong發表於2017-11-22

                   1.mysql source code install(5.7.15)

mysql版本相關知識
mysql的命名機制使用3個數字和一個後最組成的版本號
mysql-5.0.0-beta  5表示主版本號,0表示級別,9表示發行系列的版本號
 alpha -有未被測試的新程式碼
 beta  -alpha版使用一個月之後沒有致命漏洞
 rc    -發行了一段時間的beta版本
 GA    -穩定版本
 
 
mysql原始碼目錄
BUILD:各種平臺的編譯指令碼,檢測cpu型號
client:客戶端程式的原始碼
Docs:文件目錄
storage:儲存引擎目錄
sql :資料庫主程式目錄
mysys :mysql為了實現跨平臺

./configure -檢測系統是否有CC&GCC,生成makefile,
             控制mysql的編譯動作,是一個shell指令碼。
             有很多引數供選擇,具體檢視幫助
-prefix     -設定安裝路徑,預設為“/usr/local"
-datadir    -設定mysql資料檔案存放路徑
-with-charset     -設定系統的預設字符集
-with-collation   -系統預設的校驗規則
-with-extra-charsets  -除了預設字符集外需要編譯安裝的字符集
-with-unix-socket-path -設定socket檔案地址
-with-tcp-port    -指定特定監聽埠,預設為3306
-with-mysqld-user -指定執行mysqld的os的使用者,預設為mysql
-without-query-cache   -禁用query cache功能
-without-innodb        -禁用innodb儲存引擎
--with-partition       -5.1版本中開啟partition特性
--enable-thread-safe-client   -以執行緒方式編譯客戶端
-with-pthread      -強制使用pthread執行緒庫編譯
-with-named-thread-libs   -指定使用某個特定的執行緒庫編譯
-without-debug     -使用非debug模式
-with-mysqld-ldflags  -mysqld的額外link引數
-with-client-ldflags  -client的額外link引數


1.安裝依賴包
[root@bruce yum.repos.d]# yum -y install gcc-c++ ncurses-devel cmake make perl gcc autoconf automake zlib libxml libgcrypt libtool bison

2.建立mysql使用者
[root@bruce u03]# useradd mysql -d /u03/mysql

3.安裝mysql
[root@bruce u03]# ll mysql-5.7.15.tar.gz
-rwxr-xr-x 1 root root 50539618 Oct 12 15:04 mysql-5.7.15.tar.gz

[root@bruce u03]# tar -zxvf mysql-5.7.15.tar.gz
[root@bruce u03]# ll
drwxr-xr-x 35   7161    31415     4096 Aug 25 20:00 mysql-5.7.15
-rwxr-xr-x  1 root   root     50539618 Oct 12 15:04 mysql-5.7.15.tar.gz

[root@bruce u03]# cd mysql-5.7.15
[root@bruce mysql-5.7.15]# cmake -DCMAKE_INSTALL_PREFIX=/u03/mysql -DMYSQL_DATADIR=/u03/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1
CMake Error at CMakeLists.txt:21 (CMAKE_MINIMUM_REQUIRED):
  CMake 2.8.2 or higher is required.  You are running version 2.6.4


-- Configuring incomplete, errors occurred!

cmake版本太低
下載一個高版本的吧

4.安裝cmake
wget (這個直接下載有問題,還是直接firefox下載吧)
[root@bruce u03]# tar -zxvf cmake-2.8.5.tar.gz
[root@bruce u03]# cd cmake-2.8.5
[root@bruce cmake-2.8.5]# ./configure
[root@bruce cmake-2.8.5]# make
[root@bruce cmake-2.8.5]# make install

5.install mysql
[root@bruce mysql-5.7.15]# /usr/local/bin/cmake -DCMAKE_INSTALL_PREFIX=/u03/mysql -DMYSQL_DATADIR=/u03/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost
-- Running cmake version 2.8.5
-- Configuring with MAX_INDEXES = 64U
-- SIZEOF_VOIDP 8
-- MySQL 5.7.15
-- Packaging as: mysql-5.7.15-Linux-x86_64
-- Downloading boost_1_59_0.tar.gz to /usr/local/boost
-- [download 100% complete]
-- Download failed, error: 1;"unsupported protocol"
CMake Error at cmake/boost.cmake:194 (MESSAGE):
  You can try downloading
 
  manually using curl/wget or a similar tool
Call Stack (most recent call first):
  CMakeLists.txt:455 (INCLUDE)


-- Configuring incomplete, errors occurred!


還是有問題。要安裝boost庫

6.安裝boost庫
[root@bruce u03]# wget
[root@bruce u03]# ll boost_1_59_0.tar.gz
-rwxr-xr-x 1 root root 83709983 Oct 16 14:32 boost_1_59_0.tar.gz
[root@bruce u03]# tar -zxvf boost_1_59_0.tar.gz
[root@bruce u03]# mv boost_1_59_0 /usr/local/boost

7.mysql安裝
[root@bruce u03]# cd mysql-5.7.15
[root@bruce mysql-5.7.15]# /usr/local/bin/cmake -DCMAKE_INSTALL_PREFIX=/u03/mysql -DMYSQL_DATADIR=/u03/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost
[root@bruce mysql-5.7.15]# make
[root@bruce mysql-5.7.15]# make install


8.初始化mysql
[root@bruce bin]# /u03/mysql/bin/mysqld --initialize --user=mysql --basedir=/u03/mysql --datadir=/u03/mysql/data
##2016-10-16T07:20:31.918992Z 1 [Note] A temporary password is generated for root@localhost: 1ekxd;(;9ziK      #初始化後會生成預設密碼


9.調整配置檔案
[root@bruce ~]# mv /etc/my.cnf /etc/my.cnf.bak
[root@bruce ~]# cp /u03/mysql/support-files/my-default.cnf /etc/my.cnf
/etc/my.cnf加入了三個引數
basedir = /u03/mysql
datadir = /u03/mysql/data
port = 3306

10.啟動mysql
[root@bruce ~]# /u03/mysql/bin/mysqld_safe &
[1] 10129
[root@bruce ~]# 2016-10-16T07:25:21.239091Z mysqld_safe Logging to '/u03/mysql/data/bruce.err'.
2016-10-16T07:25:21.382437Z mysqld_safe Starting mysqld daemon with databases from /u03/mysql/data
[root@bruce ~]# ps -ef | grep mysql
root     10129 13805  0 15:25 pts/1    00:00:00 /bin/sh /u03/mysql/bin/mysqld_safe
mysql    10254 10129  3 15:25 pts/1    00:00:00 /u03/mysql/bin/mysqld --basedir=/u03/mysql --datadir=/u03/mysql/data --plugin-dir=/u03/mysql/lib/plugin --user=mysql --log-error=/u03/mysql/data/bruce.err --pid-file=/u03/mysql/data/bruce.pid --port=3306
root     10285 13805  0 15:25 pts/1    00:00:00 grep mysql

11.訪問資料庫
剛開始的時候登入不了資料庫,在/etc/my.cnf中加入了skip-grant-tables引數,使登入時密碼為空.
然後執行了如下語句.

update user set authentication_string=password("mysql") where user="root";

ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
這個錯誤需要執行如下操作.
update user set password_expired="N" where user="root";

完成後註釋掉/etc/my.cnf檔案中的skip-grant-tables引數

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24237320/viewspace-2147635/,如需轉載,請註明出處,否則將追究法律責任。

相關文章