SUSE Linux下源碼編譯方式安裝MySQL 5.6過程分享
來源:易賢網(wǎng) 閱讀:1075 次 日期:2014-09-30 14:02:13
溫馨提示:易賢網(wǎng)小編為您整理了“SUSE Linux下源碼編譯方式安裝MySQL 5.6過程分享”,方便廣大網(wǎng)友查閱!

MySQL為開源數(shù)據(jù)庫,因此可以基于源碼實(shí)現(xiàn)安裝。基于源碼安裝有更多的靈活性。也就是說我們可以針對自己的硬件平臺選用合適的編譯器來優(yōu)化編譯后的二進(jìn)制代碼,根據(jù)不同的軟件平臺環(huán)境調(diào)整相關(guān)的編譯參數(shù),選擇自身需要選擇不同的安裝組件,設(shè)定需要的字符集等等一些可以根據(jù)特定應(yīng)用場景所作的各種調(diào)整。本文描述了如何在源碼方式下安裝MySQL。

1、安裝環(huán)境及介質(zhì)

代碼如下:

#安裝環(huán)境

SZDB:~ # cat /etc/issue

Welcome to SUSE Linux Enterprise Server 10 SP3 (x86_64) - Kernel \r (\l).

SZDB:~ # uname -a

Linux SZDB 2.6.16.60-0.54.5-smp #1 SMP Fri Sep 4 01:28:03 UTC 2009 x86_64 x86_64 x86_64 GNU/Linux

#安裝介質(zhì),可以到以下網(wǎng)址下載安裝介質(zhì),注意下載時(shí)選擇source code,當(dāng)前版本為5.6.17

#根據(jù)你自身的環(huán)境下載相應(yīng)的安裝介質(zhì),本文演示的安裝介質(zhì)為Generic Linux (Architecture Independent), mysql-5.6.17.tar.gz

#源碼安裝方式官方網(wǎng)站鏈接:

2、系統(tǒng)需求

代碼如下:

Source Installation System Requirements

Installation of MySQL from source requires several development tools. Some of these tools are needed no matter whether you use a standard source distribution or a development source tree. Other tool requirements depend on which installation method you use.

To install MySQL from source, your system must have the following tools, regardless of installation method:

CMake, which is used as the build framework on all platforms. CMake can be downloaded from .

A good make program. Although some platforms come with their own make implementations, it is highly recommended that you use GNU make 3.75 or newer. It may already be available on your system as gmake. GNU make is available from .

A working ANSI C++ compiler. GCC 4.2.1 or later, Sun Studio 12 or later, Visual Studio 2010 or later, and many current vendor-supplied compilers are known to work.

Perl is needed if you intend to run test scripts. Most Unix-like systems include Perl. On Windows, you can use a version such as ActiveState Perl.

#使用源碼安裝上面的一些開發(fā)工具是需要的,比較重要的一個(gè)是Cmake工具,通常情況下os并沒有安裝,需要手動(dòng)安裝。

#如果沒有cmake會收到這個(gè)錯(cuò)誤提示:(-bash: cmake: command not found)

3、安裝cmake

代碼如下:

#可以到這里下載cmake,我這里下載的是2.6.4版本

SZDB:~ # cd /usr/local/src/mysql_src

SZDB:/usr/local/src/mysql_src # tar -xvf cmake-2.6.4.tar.gz

SZDB:/usr/local/src/mysql_src # cd cmake-2.6.4

SZDB:/usr/local/src/mysql_src/cmake-2.6.4 # ./bootstrap

SZDB:/usr/local/src/mysql_src/cmake-2.6.4 # ./make

SZDB:/usr/local/src/mysql_src/cmake-2.6.4 # ./make install

4、安裝MySQL

代碼如下:

SZDB:~ # groupadd mysql

SZDB:~ # useradd -r -g mysql mysql

SZDB:~ # cd /usr/local/src/mysql_src

SZDB:/usr/local/src/mysql_src # tar -xvf mysql-5.6.17.tar.gz

SZDB:/usr/local/src/mysql_src # ls

mysql-5.6.17 mysql-5.6.17.tar.gz

SZDB:/usr/local/src/mysql_src # cd mysql-5.6.17/

SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # cmake .

..........

-- Check size of wint_t - done

-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)

CMake Error at cmake/readline.cmake:85 (MESSAGE): Author : Leshami

Curses library not found. Please install appropriate package, Blog :

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:411 (MYSQL_CHECK_EDITLINE)

#如果cmake期間碰到上述錯(cuò)誤,應(yīng)該安裝ncurses-devel rpm包,然后移除CMakeCache.txt

-- Configuring incomplete, errors occurred!

#如有沒有對應(yīng)的os安裝光盤,可以從下面的鏈接下載這個(gè)rpm包,注意對應(yīng)的版本號應(yīng)一致

SZDB:/usr/local/src/mysql_src # rpm -Uvh ncurses-devel-5.5-18.11.x86_64.rpm

Preparing... ########################################### [100%]

1:ncurses-devel ########################################### [100%]

SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # rm -rf CMakeCache.txt

SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # cmake . #再次執(zhí)行cmake

........

-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl;aio

-- Configuring done

-- Generating done

-- Build files have been written to: /usr/local/src/mysql_src/mysql-5.6.17

SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # make

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

SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # make install

SZDB:/usr/local/src/mysql_src/mysql-5.6.17 # cd /usr/local/mysql

SZDB:/usr/local/mysql # chown -R mysql .

SZDB:/usr/local/mysql # chgrp -R mysql .

SZDB:/usr/local/mysql # scripts/mysql_install_db --user=mysql

..........

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:

./bin/mysqladmin -u root password 'new-password'

./bin/mysqladmin -u root -h SZDB password 'new-password'

Alternatively you can run:

./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 . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd mysql-test ; perl mysql-test-run.pl

New default config file was created as ./my.cnf and

will be used by default by the server when you start it.

You may edit this file to change server settings

..........

SZDB:/usr/local/mysql # chown -R root .

SZDB:/usr/local/mysql # chown -R mysql data

SZDB:/usr/local/mysql # cp support-files/mysql.server /etc/init.d/mysql.server #配置自啟動(dòng)

SZDB:/usr/local/mysql # cp support-files/my-default.cnf /etc/my.cnf #添加缺省的my.cnf配置文件

SZDB:/usr/local/mysql # bin/mysqld_safe --user=mysql & #啟動(dòng)mysql

[1] 21004

SZDB:/usr/local/mysql # 140521 02:54:54 mysqld_safe Logging to '/usr/local/mysql/data/SZDB.err'.

140521 02:54:54 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

#配置環(huán)境變量,通過軟鏈或者修改環(huán)境變量實(shí)現(xiàn)(PATH=$PATH:/usr/local/mysql/bin/;export PATH)

SZDB:~ # ln -fs /usr/local/mysql/bin/mysql /usr/local/bin

SZDB:~ # ln -fs /usr/local/mysql/bin/mysqladmin /usr/local/bin

SZDB:~ # ln -fs /usr/local/mysql/bin/mysqld_safe /usr/local/bin

#登陸到mysql

SZDB:/usr/local/bin # mysql -uroot

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.6.17 Source distribution

Copyright (c) 2000, 2014, 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> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| mysql |

| performance_schema |

| test |

+--------------------+

4 rows in set (0.00 sec)

更多信息請查看IT技術(shù)專欄

更多信息請查看數(shù)據(jù)庫
易賢網(wǎng)手機(jī)網(wǎng)站地址:SUSE Linux下源碼編譯方式安裝MySQL 5.6過程分享
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2025國考·省考課程試聽報(bào)名

  • 報(bào)班類型
  • 姓名
  • 手機(jī)號
  • 驗(yàn)證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 加入群交流 | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)