Linux下源碼安裝MySQL5.6.30

來源:互聯網
上載者:User

標籤:

環境簡介

linux :cenos 6.5
mysql版本:mySQL5.6.30
Mysql5.6.30安裝與mySQL5.1安裝還是有一些區別了,需要使用cmake進行安裝資訊的配置。據說Mysql從5.5以後安裝都需要cmake。
Mysql5.6.30裡面沒有configure,沒法通過./configure 進行安裝配置,需要自己去組建組態資訊

MySQL5.6.30安裝前期準備建立mysql使用者與mysql組

建立組:groupadd mysql
建立使用者:useradd -r -g mysql mysql

建立mysql檔案夾於資料存放檔案夾data

mkdir -p /usr/local/mysql/data

安裝cmake


當然也可使用yum安裝命令如下
yum install cmake -y

安裝資訊配置

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/localhost/mysql/data

執行make && make install

進行相應的配置

1.conf:用於儲存mysql配置資訊
mkdir /usr/local/mysql/conf
2.var:用來存放mysql運行時檔案
mkdir /usr/local/mysql/var
3.將support-files裡面的my-default.cnf移到conf裡面,並改名為my.cnf

4.分配許可權
chown -R mysql:mysql /usr/local/mysql

初始化mysql


/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --skip-name-resolve--user=mysql --defaults-file=/usr/local/mysql/conf/my.cnf--pid-file=/usr/local/mysql/var/mysql.pid--socket=/usr/local/mysql/var/mysql.sock

啟動與關閉mysql

啟動:support-files/mysql.server start
關閉:support-files/mysql.server stop

串連mysql

mysql安裝好之後的目錄結構

啟動之前與後比較如

安裝可能遇到問題解決問題1

./configure 的時候報一下的錯誤,可以嘗試這樣解決
Mysql安裝:/bin/rm: cannot remove libtoolt‘: No such file or directory .
編譯MySQL的過程中提示:
/bin/rm: cannot remove
libtoolt’: No such file or directory
解決:
1、確認libtool是否已經安裝,如果沒有安裝的話,則先安裝libtool

yum -y install libtool

2、分別執行以下三條命令:

autoreconf –force –installlibtoolize –automake –forceautomake –force –add-missing

再重新編譯安裝,問題解決!

問題二

缺少ncurses-devel包
錯誤資訊如下

解決版本
解決方式(CentOS)
yum list|grep ncurses
yum -y install ncurses-devel

問題三

當執行mysql_install_db初始化mysql時候
發現已經存在my.cn檔案,很有可能是系統之前安裝了mysql沒有卸載乾淨導致的

my.cn檔案如下

這樣就導致了,本地usr/local/mysql/var中沒有產生mysql.sock檔案
解決辦法:
移除/etc/my.cn,然後重新初始化
問題四:如果啟動mysql出現找不到**.pid檔案問題
問題出錯介面如下

修改my.cnf設定檔,指定資料庫所在檔案,如下

執行bin/mysqld_safe &
在執行support-files/mysql.server start

Linux下源碼安裝MySQL5.6.30

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.