1. 程式人生 > >MySQL5.6.12原始碼編譯安裝詳細過程

MySQL5.6.12原始碼編譯安裝詳細過程

本人轉自:http://blog.csdn.net/mchdba/article/details/35994251

1 下載安裝包download tar.gz

wget http://download.csdn.net/detail/mchdba/7545037

ps:修改yum源為163.

看個人情況而定,可以忽略

cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
mv CentOS-Base.repo CentOS-Base.repo.bak
mv CentOS6-Base-163.repo CentOS-Base.repo
yum clean all
2 安裝cmake軟體包 yum install cmake -y

3 create account of mysql
groupadd mysql           
useradd -g mysql mysql           
autoreconf --force --install
libtoolize --automake --force
automake --force --add-missing
注意autoreconf和automake可以通過yum install automake -y
libtoolize可以通過yum install libtool -y

4  complie the sources

資料目錄  : /home/data/mysql/data
mysql軟體目錄  : /usr/local/mysql
mkdir -p /home/data/mysql/data
mkdir -p /usr/local/mysql
tar -xvf mysql-5.6.12.tar.gz 
cd mysql-5.6.12

5 預編譯

[[email protected] mysql-5.6.12]# time cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/home/data/mysql/data -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR==/usr/local/mysql/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

time cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DMYSQL_DATADIR=/home/data/mysql/data/ -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci > tlog.log 2>tlogerr.log
然後檢視tlogerr.log日誌,看裡面是否有ERROR資訊,WARNING沒關係.
# more tlogerr.log
......
-- 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:85 (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:128 (FIND_CURSES)
  cmake/readline.cmake:202 (MYSQL_USE_BUNDLED_EDITLINE)
  CMakeLists.txt:325 (MYSQL_CHECK_EDITLINE)

-- Configuring incomplete, errors occurred!
real 0m41.872s
user 0m23.508s
sys 0m16.328s

可能會出的問題:

CMake was unable to find a build program corresponding to "Unix Makefiles".....CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool..

大概的意思就是說cmake沒有安裝好,解決辦法就是

yum install make -y

再預編譯就可以了.


6 yum install make
ok
[[email protected] mysql-5.6.13]# 

[解決辦法]

刪除當前目錄中的CMakeCache.txt

[[email protected] mysql-5.6.12]# rm -fCMakeCache.txt

安裝ncurses-devel
yum -y install ncurses-devel

再報錯如下:
-- Performing Test HAVE_PEERCRED
CMake Error at /usr/share/cmake/Modules/CMakeCXXInformation.cmake:17 (GET_FILENAME_COMPONENT):
  get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
  CMakeLists.txt:3 (PROJECT)


CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Performing Test HAVE_PEERCRED - Failed
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
-- Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://foo.bar.com:80
Warning: Bison executable not found in PATH
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- Configuring incomplete, errors occurred!

real 0m42.841s
user 0m24.527s
sys 0m16.543s
-- Configuring incomplete, errors occurred!

real    0m0.510s
user    0m0.275s
sys     0m0.112s
[[email protected] mysql-5.6.13]# 
yum install gcc gcc-c++ -y
yum install -y ncurses-devel.x86_64
yum install -y cmake.x86_64
yum install -y libaio.x86_64
yum install -y bison.x86_64
yum install -y gcc-c++.x86_64

[解決辦法]:

刪除原來的mysql-5.6.12目錄,重新解壓縮tar.gz包


8 重新執行編譯
rm -rf /root/mysql-5.6.12
cd /root/
tar -xvf mysql-5.6.12.tar.gz 
cd /root/mysql-5.6.12
time cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql/ -DMYSQL_DATADIR=/home/data/mysql/data/ -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci > tlog.log 2>tlogerr.log

real 0m45.943s
user 0m26.213s
sys 0m17.661s

等待執行完後先檢視more tlogerr.log看裡面是否有ERROR資訊,WARNING沒關係.如果有,反覆刪除當前目錄中的CMakeCache.txt,解決ERROR,再執行 cmake直到沒有error資訊為止.

再檢視more tlog.log如果輸出如下資訊就可以進行make操作了.

-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
-- Googlemock was not found. gtest-based unit tests will be disabled. You can run cmake . -DENABLE_
DOWNLOADS=1 to automatically download and build required components from source.
-- If you are inside a firewall, you may need to use an http proxy: export http_proxy=http://foo.ba
r.com:80
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl
-- Configuring done
-- Generating done
-- Build files have been written to: /root/downloads/mysql-5.6.12

執行MAKE操作:

# time make 

這一步時間比較長,需要耐心等待,看中間是否有error資訊產生。
會看到很多Building資訊
......
[ 38%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/lock/lock0iter.cc.o
[ 38%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/lock/lock0lock.cc.o
[ 38%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/lock/lock0wait.cc.o
[ 38%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/log/log0log.cc.o
[ 39%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/log/log0recv.cc.o
[ 39%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/mach/mach0data.cc.o
[ 39%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/mem/mem0mem.cc.o
......
[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

real 21m39.375s
user 18m9.239s
sys 1m34.320s

time make install
這個命令比較快
......
-- Installing: /usr/local/mysql/man/man8/mysqld.8
-- Installing: /usr/local/mysql/support-files/solaris/postinstall-solaris

real 0m8.439s
user 0m3.353s
sys 0m4.616s

9 init db,初始化資料庫
ll /home/data/mysql/data
cd /home/data/mysql/data

先賦予資料夾mysql許可權

chown -R mysql /home/data/mysql/data
chgrp -R mysql /home/data/mysql/data
chown -R mysql /usr/local/mysql/
chgrp -R mysql /usr/local/mysql/
cd /usr/local/mysql/
cp support-files/my-default.cnf /etc/my.cnf
編輯my.cnf,參考本文最後配置.編輯完後執行下面命令:
[[email protected] mysql]# scripts/mysql_install_db  --user=mysql --basedir=/usr/local/mysql --datadir=/home/data/mysql/data --defaults-file=/etc/my.cnf
Installing MySQL system tables.../usr/local/mysql/bin/mysqld: File '/home/data/mysql/binlog/mysql-bin.index' not found (Errcode: 2 - No such file or directory)
2014-06-27 10:47:14 9686 [ERROR] Aborting

2014-06-27 10:47:14 9686 [Note] Binlog end
2014-06-27 10:47:14 9686 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete

[[email protected] mysql]# mkdir -p /home/data/mysql/binlog/
[[email protected] mysql]#
[[email protected] mysql]# chown -R mysql /home/data/mysql/binlog/
[[email protected] mysql]# chgrp -R mysql /home/data/mysql/binlog/
建好目錄,再執行資料庫初始化:
[[email protected] mysql56]# scripts/mysql_install_db  --user=mysql --basedir=/usr/local/mysql --datadir=/home/data/mysql/data --defaults-file=/etc/my.cnf
Installing MySQL system tables...2013-08-22 05:06:03 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-08-22 05:06:03 19416 [Note] InnoDB: The InnoDB memory heap is disabled
2013-08-22 05:06:03 19416 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2013-08-22 05:06:03 19416 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-08-22 05:06:03 19416 [Note] InnoDB: Using CPU crc32 instructions
2013-08-22 05:06:03 19416 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2013-08-22 05:06:03 19416 [Note] InnoDB: Completed initialization of buffer pool
2013-08-22 05:06:03 19416 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2013-08-22 05:06:03 19416 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2013-08-22 05:06:03 19416 [Note] InnoDB: Database physically writes the file full: wait...
2013-08-22 05:06:03 19416 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2013-08-22 05:06:03 19416 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2013-08-22 05:06:03 19416 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2013-08-22 05:06:03 19416 [Warning] InnoDB: New log files created, LSN=45781
2013-08-22 05:06:03 19416 [Note] InnoDB: Doublewrite buffer not found: creating new
2013-08-22 05:06:03 19416 [Note] InnoDB: Doublewrite buffer created
2013-08-22 05:06:03 19416 [Note] InnoDB: 128 rollback segment(s) are active.
2013-08-22 05:06:03 19416 [Warning] InnoDB: Creating foreign key constraint system tables.
2013-08-22 05:06:03 19416 [Note] InnoDB: Foreign key constraint system tables created
2013-08-22 05:06:03 19416 [Note] InnoDB: Creating tablespace and datafile system tables.
2013-08-22 05:06:03 19416 [Note] InnoDB: Tablespace and datafile system tables created.
2013-08-22 05:06:03 19416 [Note] InnoDB: Waiting for purge to start
2013-08-22 05:06:03 19416 [Note] InnoDB: 5.6.13 started; log sequence number 0
2013-08-22 05:06:04 19416 [Note] Binlog end
2013-08-22 05:06:04 19416 [Note] InnoDB: FTS optimize thread exiting.
2013-08-22 05:06:04 19416 [Note] InnoDB: Starting shutdown...
2013-08-22 05:06:05 19416 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK

Filling help tables...2013-08-22 05:06:05 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2013-08-22 05:06:05 19439 [Note] InnoDB: The InnoDB memory heap is disabled
2013-08-22 05:06:05 19439 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2013-08-22 05:06:05 19439 [Note] InnoDB: Compressed tables use zlib 1.2.3
2013-08-22 05:06:05 19439 [Note] InnoDB: Using CPU crc32 instructions
2013-08-22 05:06:05 19439 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2013-08-22 05:06:05 19439 [Note] InnoDB: Completed initialization of buffer pool
2013-08-22 05:06:05 19439 [Note] InnoDB: Highest supported file format is Barracuda.
2013-08-22 05:06:05 19439 [Note] InnoDB: 128 rollback segment(s) are active.
2013-08-22 05:06:05 19439 [Note] InnoDB: Waiting for purge to start
2013-08-22 05:06:05 19439 [Note] InnoDB: 5.6.13 started; log sequence number 1625977
2013-08-22 05:06:05 19439 [Note] Binlog end
2013-08-22 05:06:05 19439 [Note] InnoDB: FTS optimize thread exiting.
2013-08-22 05:06:05 19439 [Note] InnoDB: Starting shutdown...
2013-08-22 05:06:06 19439 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

  /usr/local/mysql56/bin/mysqladmin -u root password 'new-password'
  /usr/local/mysql56/bin/mysqladmin -u root -h 472322.ea.com password 'new-password'

Alternatively you can run:

  /usr/local/mysql56/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
  cd . ; /usr/local/mysql56/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
  cd mysql-test ; perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
The latest information about MySQL is available on the web at
  http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as /usr/local/mysql56/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server
[[email protected] mysql56]# 

10 copy start command 
cp support-files/mysql.server /etc/init.d/mysqld5612
chmod 700 /etc/init.d/mysqld5612
echo "export PATH=$PATH:/usr/local/mysql/bin">>/etc/profile 
source /etc/profile

11 新增開機啟動
chkconfig --add mysqld5612

12  start service 
service mysqld5612 start
[[email protected] mysql]# service mysqld5612 start
Starting MySQL.......The server quit without updating PID f[失敗]usr/local/mysql/mysqld.pid).
[[email protected] mysql]# 
檢視日誌報錯如下:
2014-06-24 14:56:54 31726 [Note] Server socket created on IP: '::'.
2014-06-24 14:56:54 31726 [ERROR] Can't start server : Bind on unix socket: Permission denied
2014-06-24 14:56:54 31726 [ERROR] Do you already have another mysqld server running on socket: /usr/local/mysql/mysql.sock ?
2014-06-24 14:56:54 31726 [ERROR] Aborting
解決原因是:
/usr/local/mysql跟目錄需要賦予mysql許可權
根據日誌檔案顯示,首先檢查執行許可權,再看一下/usr/local/mysql/mysql.sock,發現/usr/local/mysql目錄下並沒有該檔案,是否是沒有許可權寫目錄?
看到/usr/local/mysql目錄是root使用者,所以賦予mysql操作許可權。
chown -R mysql.mysql /usr/local/mysql

[[email protected] data56]# service mysqld5612 start
Starting MySQL. SUCCESS! 
[[email protected] data56]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.13 Source distribution

Copyright (c) 2000, 2013, 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.

相關推薦

MySQL5.6.12原始碼編譯安裝詳細過程

本人轉自:http://blog.csdn.net/mchdba/article/details/35994251 1 下載安裝包download tar.gz wget http://download.csdn.net/detail/mchdba/7545037​ ps:

SuSE11安裝MySQL5.6.40:編譯安裝方式、單實例

conf set mysq user defaults als back -a 用戶 摘要:SuSE11sp3 64位操作系統、 MySQL5.6.40 編譯安裝、單實例註:kingtry是我的主機名一、環境準備操作系統:SuSE版本11sp3,64位kingtry:~ #

超簡單!!centos 6離線原始碼編譯安裝升級gcc、binutils、automake、autoconf

centos 6系列的Linux發行版,是非常成功(具足UNIX精神)的發行版,可能大家都已經用得非常習慣了。 但問題是,其核心及附帶的工具軟體,版本卻都非常老了。 centos 7上的軟體版本雖然比較新,但centos 7設計風格的突變(主要是引入了很不符合UNIX精神的systemd),可能在業

Linux下MySQL 5.5.12原始碼編譯安裝.

本文部分是網上搜索得到,但是合併幾個不同方法,解決了幾個遇到的問題。並且把解決方法一併貼到安裝步驟中,希望能夠有參考作用。選擇mysql5.5.12,目前是比較穩定的一個版本。安裝步驟:1、安裝cmak

ubuntu 12.04編譯vlc詳細過程

本文介紹ubuntu下android-vlc編譯的過程,主要記錄了編譯過程中碰的到問題及解決方案,如果可以為其他人編譯vlc提供幫助,將是我的榮幸。 一 編譯環境搭建: 1.下載配置NDK環境: 使用版本android-ndk-r9 下載地址:http://www.12

MySQL5.6原始碼編譯安裝(CentOS-6.6+MySQL-5.6)(一)

原文地址:http://my.oschina.net/wushuicheng/blog/551621 《基於Dubbo的分散式系統架構視訊教程》 高可用架構篇 MySQL原始碼編譯安裝(CentOS-6.6+MySQL-5.6) 部署環

mysql 5.6.25編譯安裝詳細步驟

dir 支持斷點續傳 啟動項 ++ roo blog eve files 文件 1 #安裝依賴 2 yum -y install make gcc-c++ cmake bison-devel ncurses-devel perl vim 3 4

centos6.8下安裝部署LNMP(備註:nginx1.8.0+php5.6.10+mysql5.6.12

debug pcr chkconfig c++ sam libjpeg php 執行 btool 在平時運維工作中,經常需要用到LNMP應用框架。以下對LNMP環境部署記錄下: 1)前期準備:為了安裝順利,建議先使用yum安裝依賴庫[root@opd ~]#yum ins

原始碼編譯安裝MySQL-5.6/mysql-5.6.39------踩了無數坑,重灌了十幾次伺服器才會的,不容易啊!

1.切換到src目錄 cd /usr/local/src/   2. 下載mysql免編譯二進位制包  免編譯的mysql二進位制包5.6原始碼包: wget http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.3

原始碼編譯安裝PHP Version 5.6.30------踩了無數坑,重灌了十幾次伺服器才會的,不容易啊!

1 環境準備 yum install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-deve

02-原始碼編譯安裝測試postgresql 9.6.1(2017-02-07)

1下載安裝包postgresql 961 2軟體下載 3解壓 1 安裝依賴包 2 增加使用者設定密碼 4配置編譯選項 5編譯

mysql5.6.35原始碼安裝記錄

mysql資料庫原始碼安裝: 原始碼地址:wget http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.xx.tar.gz  #安裝前準備,將編譯工具、依賴環境通過yum安裝 yum  install  cmake  ncurses-devel

Linux下MySQL原始碼編譯安裝(eg:mysql-5.6.27.tar.gz )

Linux下MySQL原始碼安裝(eg:mysql-5.6.27.tar.gz ): 1:準備MySQL原始碼安裝包: mysql-5.6.27.tar.gz、cmake-3.3.2.tar.gz、ncurses-6.0.tar.gz 注:centos請安裝: yum in

【Elasticsearch 5.6.12 原始碼】——【3】啟動過程分析(下)

版權宣告:本文為博主原創,轉載請註明出處! 簡介 本文主要解決以下問題: 1、ES啟動過程中的Node物件都初始化了那些服務? 構造流程 Step 1、建立一個List暫存初始化失敗時需要釋放的資源,並使用臨時的Logger物件輸出開始初始化的日誌。 這裡首先建立了一個List

【Elasticsearch 5.6.12 原始碼】——【2】啟動過程分析(上)

版權宣告:本文為博主原創,轉載請註明出處! 簡介 本文主要解決以下問題: 1、啟動ES的入口類及入口方法是哪個?2、分析梳理ES服務啟動的主要流程? 入口類 ES的入口類為org.elasticsearch.bootstrap.Elasticsearch,啟動方法為: public

在linux通過原始碼編譯安裝redis詳細步驟

1.下載原始碼包 [[email protected] opt]# wget http://download.redis.io/releases/redis-4.0.10.tar.gz 2.解壓縮redis [[email protected] opt]# tar

centos系統上mysql5.6.12版本安裝

1.安裝相關的工具 yum install gcc gcc-c++ yum install make yum install ncurses-devel yum install cmake -y 2.下載軟體包 wget http://dev.my

pycuda的安裝和錯誤解決(含boost安裝編譯詳細過程

需要準備: 1.pytools庫安裝PyCUDA還需要pytools庫,pytools庫需要six,appdirs,decorator這三個庫,可以通過easy_install進行安裝. 這裡提供一個地址,包含很多包,不過現在都是whl格式的,可以通過pip指令進行安裝 h

CentOS 6.5使用原始碼編譯安裝httpd服務

httpd是一個開源軟體,且一般用作web伺服器來使用。目前最流行的web伺服器軟體叫做httpd, 在早期的http server就叫做apache,到了http server 2.0以後就改名為httpd了。 所以有時候聽到apache伺服器和httpd伺服器其實都是指得

Linux系統MySQL5.7原始碼編譯安裝筆記【Ubuntu篇】

①安裝依賴      原始碼編譯安裝需要若干Linux系統環境依賴,詳細參考https://dev.mysql.com/doc/refman/5.7/en/source-installation.html。就Ubuntu16.04LTS而言,執行以下安裝命令就OK了(如果有