Linux下源碼安裝MySQL 5.6(經典)

來源:互聯網
上載者:User

標籤:mysql 5.6

一、安裝前準備

1.安裝make編譯器

make編譯器:http://www.gnu.org/software/make/

(系統預設內建)查看自己的系統是否安裝某個軟體,如果已經有了,就不用在安裝了,但是也有可能之前被卸載           了。

如果你之前是使用rpm -ivh make裝的,用

# rpm -qa | grep make肯定是能夠找到的。

如果你是用

make && make install裝的。那麼最好直接去找執行程式,就知道有沒裝上去

# find / -name matlab

如果裝了,它會告訴你執行程式被釋放到哪個目錄了。

++++++++++++++++++++++++++++++++++++++++++

# rpm -qa 是查看該軟體是否被安裝,# grep和# find是查看檔案位置

++++++++++++++++++++++++++++++++++++++++++

# tar zxvf make-3.82.tar.gz 

# cd make-3.82 

# ./configure 

# make 

# make install 

 

 

2.安裝bison

bison:http://www.gnu.org/software/bison/

 

 

# tar zxvf bison-2.5.tar.gz 

# cd bison-2.5 

# ./configure 

# make 

# make install 

3.安裝gcc-c++

gcc-c++:http://www.gnu.org/software/gcc/

 

# tar zxvf gcc-c++-4.4.4.tar.gz 

# cd gcc-c++-4.4.4 

#./configure 

# make 

# make install 

4.安裝cmake

cmake:http://www.cmake.org/

 

# tar zxvf cmake-2.8.4.tar.gz 

# cd cmake-2.8.4 

#./configure 

# make 

# make install 

5.安裝ncurses

ncurses:http://www.gnu.org/software/ncurses/

 

# tar zxvf ncurses-5.8.tar.gz 

# cd ncurses-5.8 

#./configure 

# make 

# make install 


二、Mysql安裝過程

1、基礎安裝和配置

MySQL5.6:http://dev.mysql.com/ 

這裡我在這裡下載的mysql-5.6.12.tar.gz

ftp://mirror.switch.ch/mirror/mysql/Downloads/MySQL-5.6/

準備工作

# groupadd mysql 

# useradd mysql -g mysql -M -s /sbin/nologin 

#增加一個名為 mysql的使用者。

-g:指定新使用者所屬的使用者組(group)

-M:不建立根目錄

-s:定義其使用的shell,/sbin/nologin代表使用者不能登入系統。

 

解壓並安裝MySQL

# tar zxvf mysql-5.6.12.tar.gz 

# cd mysql-5.6.12 

# cmake ./

# make 

# make install 

# cd /usr/local/mysql 

# chown -R mysql:mysql .    (#這裡最後是有個.的大家要注意# 為了安全安裝完成後請修改許可權給root使用者)

# scripts/mysql_install_db --user=mysql    (先進行這一步再做如下許可權的修改)

# chown -R root:mysql .     (將使用權限設定給root使用者,並設定給mysql組, 取消其他使用者的讀寫執行許可權,僅留給mysql "rx"讀執行許可權,其他使用者無任何許可權)

# chown -R mysql:mysql ./data    (資料庫存放目錄設定成mysql使用者mysql組)

# chmod -R ug+rwx  .     (賦予讀寫執行許可權,其他使用者權限一律刪除僅給mysql使用者權限)

 

下面的命令是將mysql的設定檔拷貝到/etc

# cp support-files/my-default.cnf  /etc/my.cnf

(5.6之前的版本用如下命令)

# cp support-files/my-medium.cnf /etc/my.cnf  (5.6之前的版本是此操作,讀者也可在此時自己進入support-files檔案夾下面,看是設定檔的真正名稱,那個存在,就拷貝那個。。)

修改my.cnf配置

   # vi /etc/my.cnf

    

#[mysqld] 下面添加:

 user=mysql

   datadir=/data/mysql

 default-storage-engine=MyISAM


#chmod -R 755 /usr/local/mysql/data

用命令“ps -ef|grep mysqld”查看是否有mysqld進程,如果有使用“kill -9  進程號”殺死,然後重新啟動mysqld!
  #關閉seLinux  開啟/etc/selinux/config,把SELINUX=enforcing改為SELINUX=disable

2、啟動和檢驗mysql

啟動mysql

# bin/mysqld_safe --user=mysql &        或者直接進入bin檔案夾下面

# cd bin

#./mysqld                              \ 這裡說明,mysqld_safe或者mysqld都可以啟動的

啟動mysql,看是否成功 

# ps –ef|grep mysql

 650) this.width=650;" name="image_operate_29041378125270236" src="http://s8.sinaimg.cn/mw690/6d39ac7egx6CleK1fjp47&690" width="637" height="155" alt="Linux下源碼安裝MySQL <wbr>5.6" title="Linux下源碼安裝MySQL <wbr>5.6" style="margin:0px;padding:0px;border:0px;list-style:none;width:561px;height:135px;" />

 

# netstat -tnl|grep 3306 

650) this.width=650;" name="image_operate_99131378124942136" src="http://s12.sinaimg.cn/mw690/6d39ac7egx6CleOLG9Z3b&690" width="644" height="58" alt="Linux下源碼安裝MySQL <wbr>5.6" title="Linux下源碼安裝MySQL <wbr>5.6" style="margin:0px;padding:0px;border:0px;list-style:none;width:564px;height:49px;" />

 

上面是一種啟動mysql的方法,還有一種簡單的方便,如下:

將mysql的啟動服務添加到系統服務中 

# cp support-files/mysql.server  /etc/init.d/mysql 

現在可以使用下面的命令啟動mysql 

# service mysql start 

停止mysql服務 

# service mysql stop 

重啟mysql服務 

# service mysql restart 

 

 650) this.width=650;" name="image_operate_13951378125268946" src="http://s7.sinaimg.cn/mw690/6d39ac7egx6CleTjRFs36&690" width="542" height="97" alt="Linux下源碼安裝MySQL <wbr>5.6" title="Linux下源碼安裝MySQL <wbr>5.6" style="margin:0px;padding:0px;border:0px;list-style:none;width:509px;height:91px;" />


3、密碼修改:

# chkconfig --add mysql

修改預設root賬戶密碼,預設密碼為空白

修改密碼 cd 切換到mysql所在目錄

# cd /usr/local/mysql

# ./bin/mysqladmin -u root password

斷行符號在接下來的提示中設定新密碼即可。。

650) this.width=650;" name="image_operate_66451378125266709" src="http://s12.sinaimg.cn/mw690/6d39ac7egx6Clf4yf2z6b&690" width="456" height="108" alt="Linux下源碼安裝MySQL <wbr>5.6" title="Linux下源碼安裝MySQL <wbr>5.6" style="margin:0px;padding:0px;border:0px;list-style:none;width:458px;height:112px;" />

 

最後

# service mysql restart;              (重啟mysql伺服器)

# cd /usr/local/mysql/bin/        (進入mysql basedir下面的bin中)

# ./mysql -u root -p                              (開啟用戶端)

# use mysql

以上就是整個過程,so perfect!

本文出自 “PETER-疏狂少年” 部落格,請務必保留此出處http://petervip.blog.51cto.com/3790959/1679259

Linux下源碼安裝MySQL 5.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.