Linux RedHat 6.4 MySQL5.6源碼包安裝

來源:互聯網
上載者:User

標籤:源碼安裝   linux   軟體包   mysql源碼   

一、準備工作:

1、查詢系統中已安裝的MySQL相關軟體包  

[[email protected] ~]# rpm -qa|grep -i  mysql

2、如果MySQL已開啟,停止運行MySQL伺服器    

[[email protected] ~]#service mysqld stop             

3、卸載系統包

[[email protected] ~]# rpm -e perl-DBD-MySQL-4.013-3.el6.x86_64 --nodeps

[[email protected] ~]# rpm -e mysql-libs-5.1.66-2.el6_3.x86_64 --nodeps

[[email protected] ~]# rpm -e qt-mysql-4.6.2-25.el6.x86_64 --nodeps


二、安裝編譯

1、MySQL編譯依賴

(1)、必備的包和工具

    gcc/g++ :MySQL 5.6開始,需要使用g++進行編譯。

    cmake  :MySQL 5.5開始,使用cmake進行工程管理,cmake需要2.8以上版本。

    bison   :MySQL文法解析器需要使用bison進行編譯。

    ncurses-devel :用於終端操作的開發包。

    zlib    :MySQL使用zlib進行壓縮。

(2)、功能需要的包

    libxml   :用於XML輸入輸出方式的支援。

    openssl  :使用openssl安全通訊端方式通訊。

    dtrace   :用於診斷MySQL問題。

2、MySQL基本編譯參數

cmake 參數說明手冊參考:http://www.blogjava.net/kelly859/archive/2012/09/04/387005.html

--CMAKE_BUILD_TYPE  //編譯的版本類型:RelWithDebInfo和Debug,不同之處是RelWithDebInfo會進行最佳化。

--CMAKE_INSTALL_PREFIX //指定make install安裝的目標路徑。

--SYSCONFDIR //指定設定檔的預設路徑。

--MYSQL_DATADIR //指定data目錄的預設路徑.

--WITH_DEBUG // 指定是否有debugging資訊,一般用於源碼調試時,開啟WITH_DEBUG,生產環境關閉。

--ENABLED_PROFILING //指定是否可以使用show profile顯示操作執行的詳細資料。

--DEFAULT_CHARSET //指定預設字元集,可以在啟動的設定檔中指定。

--DEFAULT_COLLATION // 指定預設字元比較、排序的規則

--WITH_EXTRA_CHARSETS //指定其他可能使用的字元集。

--WITH_SSL //指定SSL的類型,從5.6.6開始預設bundled類型,此外也可以指定SSL庫的路徑地址。

--WITH_ZLIB //指定zlib的類型,用於壓縮功能。

--WITH_storage_STORAGE_ENGINE //指定編譯支援的儲存引擎,預設支援MyISAM,MERGE,MEMORY,CSV儲存引擎。

--ENABLED_LOCAL_INFILE //指定是否允許使用load data infile功能。

--WITH_EMBEDDED_SERVER //指定是否編譯libmysqld嵌入式庫

--INSTALL_LAYOUT //指定安裝的布局類型。


3、安裝資訊

   作業系統 RedHat 6.4

   [[email protected] ~]# cat /etc/issue

   Red Hat Enterprise Linux Server release 6.4 (Santiago)

   MySQL 版本 5.6.23

   :http://www.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.23.tar.gz/from/http://cdn.mysql.com/

   安裝目錄為:/app/mysql/

   資料目錄為:/data/mysqldata 

   儲存引擎包括:MEMORY,MyISAM,InnoDB等 

   字元集為:UTF8

4、安裝源碼說依賴的庫

   [[email protected] ~]# yum -y install gcc gcc-c++ autoconf   zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* 

5、下載所需軟體包:

  #將下載的檔案都放到/opt目錄下,如下

  cmake:http://www.cmake.org/files/v2.8/cmake-2.8.11.1.tar.gz

  bison:http://ftp.gnu.org/gnu/bison/bison-2.7.tar.gz

  m4:http://ftp.gnu.org/gnu/m4/m4-1.4.16.tar.gz

6、所需包

  安裝cmake編譯器

  [[email protected] ~]# cd /opt

  [[email protected] ~]# tar -xvf cmake-2.8.11.1.tar.gz

  [[email protected] ~]# cd cmake-2.8.11.1

  [[email protected] ~]# ./bootstrap

  [[email protected] ~]# make && make install


安裝m4

  [[email protected] ~]# tar -xvf m4-1.4.16.tar.gz

  [[email protected] ~]# cd m4-1.4.16

  [[email protected] ~]# ./configure && make && make install


安裝bison

  [[email protected] ~]# tar -xvf bison-2.7.tar.gz

  [[email protected] ~]# cd bison-2.7

  [[email protected] ~]# ./configure && make && make install

7、建立mysql使用者與組,相關目錄

[[email protected] ~]# /usr/sbin/groupadd mysql

[[email protected] ~]# /usr/sbin/useradd -g mysql mysql

[[email protected] ~]# mkdir -p /app/mysql

[[email protected] ~]# chown -R mysql:mysql /app/mysql

[[email protected] ~]# mkdir -p /data/mysqldata

[[email protected] ~]# chown -R mysql:mysql /data/mysqldata/ 


8、編譯安裝mysql

[[email protected] opt]# tar -zxvf mysql-5.6.23.tar.gz

[[email protected] opt]# cd mysql-5.6.23

[[email protected] mysql-5.6.23]# export CFLAGS="-O3 -g -fno-exceptions -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing"

[[email protected] mysql-5.6.23]# export CXXFLAGS="-O3 -g -fno-exceptions -fno-rtti -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing"

[[email protected] mysql-5.6.23]# export CXX=g++

[[email protected] mysql-5.6.23]# cmake -DCMAKE_INSTALL_PREFIX=/app/mysql/ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \

     -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=utf8,gbk  \

     -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 \

     -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/mysqldata/ -DSYSCONFDIR=/etc \

     -DWITH_SSL=bundled -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 \

     -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DENABLE_DOWNLOADS=1 \

[[email protected] mysql-5.6.23]# make && make install

9、初始化資料庫

拷貝mysql設定檔

[[email protected] mysql-5.6.23]# cp support-files/my-default.cnf /etc/my.cnf 

[[email protected] ~]# cd /app/mysql/scripts/

[[email protected] scripts]# ./mysql_install_db --user=mysql  --basedir=/app/mysql --datadir=/data/mysqldata/ 


10、配置環境變數

[[email protected] ~]# vim /etc/profile

PATH=/app/mysql/bin:/app/mysql/lib:$PATH

export PATH

[[email protected] ~]# source /etc/profile


11、設定開機啟動

[[email protected] mysql-5.6.23]# cp support-files/mysql.server /etc/init.d/mysqld

[[email protected] mysql-5.6.23]# chkconfig --add mysqld

[[email protected] mysql-5.6.23]# chkconfig --list mysqld

mysqld          0:關閉  1:關閉  2:啟用  3:啟用  4:啟用  5:啟用  6:關閉

[[email protected] mysql-5.6.23]# chmod 755 /etc/init.d/mysqld 

[[email protected] mysql-5.6.23]# service mysqld start

Starting MySQL..[確定]


12、初始化root密碼

[[email protected] ~]#/app/mysql/bin/mysqladmin -u root password ‘123456‘


遇到問題 如果不能初始化密碼,出現ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)

[[email protected] ~]# /etc/init.d/mysql stop

[[email protected] ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

[[email protected] ~]# mysql

UPDATE user SET password=PASSWORD(‘123456‘) WHERE user=‘root‘;

FLUSH PRIVILEGES;

[[email protected] ~]# mysql -uroot -p123456


13、訪問授權

[[email protected] ~]#mysql/bin/mysql -uroot -p         #敲入該命令後,螢幕會提示輸入密碼,輸入上一步設定的密碼

    刪除root密碼為空白的記錄

    mysql> use mysql;

    mysql> delete from user where password=‘‘;

    mysql> flush privileges;

    配置mysql允許root遠程登入                                  #登入

    mysql> grant all privileges on *.* to [email protected]‘%‘ identified by "123456";

    mysql> flush privileges;

    mysql> select User,Password,Host from user;


Linux RedHat 6.4 MySQL5.6源碼包安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.