Centos系統下面MySql資料庫源碼包編譯

來源:互聯網
上載者:User

標籤:mysql   centos   資料庫   源碼包編譯   

第一步:配置好網路環境,下載cmake軟體包(mysql5.5以後是通過cmake來編譯的)
wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz

第二步:壓解軟體包cmake
tar -zxvf /data/cmake-2.8.5.tar.gz

進入 cmake-2.8.5

第三步:安裝軟體包gcc-c++

yum -y install gcc-c++

第四步:執行./configure來編譯cmake
./configure

make && make install


第五步:建立mysql的安裝目錄及資料庫存放的目錄
mkdir -p /data/mysql   //安裝mysql

mkdir -p /data/mysql/mysqldb  //存放資料庫

第六步:建立mysql使用者及使用者組

groupadd mysql

useradd -r -g mysql mysql

第七步:安裝mysql
tar -zxvf mysql-5.6.24.tar.gz

cd /mysql-5.6.24

第八步:安裝軟體包ncurses-devel

yum -y install ncurses-devel

第九步:進行mysql檔案編譯
cmake . \
-DCMAKE_INSTALL_PREFIX=/data/mysql \
-DMYSQL_DATADIR=/data/mysql/mysqldb \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_TCP_PORT=3306 \
-DEXTRA_CHARSETS=all \
-DENABLE_DOWNLOADS=1 \
-DENABLED_LOCAL_INFILE=1

註:重新回合組態,需要刪除CMakeCache.txt檔案
cd /data/cmake-2.8.5
make clean
rm -rf /etc/my.cnf
rm -rf CMakeCache.txt


make && make install (此步驟需要十分鐘)

第十步:配置mysql服務
[[email protected] ~]# chown -R mysql:mysql /data/mysql
[[email protected] ~]# chown -R mysql:mysql /data/mysql/mysqldb

第十一步:拷貝support-files/my-default.cnf為/etc/my.cnf(註:如果/etc/my.cnf檔案存在,則覆蓋)
cp support-files/my-default.cnf /etc/my.cnf

第十二步:初始化mysql資料庫
cd /data/mysql
scripts/mysql_install_db --user=mysql --datadir=/data/mysql/mysqldb


第十三步:複製mysql服務啟動指令碼及加入PATH路徑
cd /data/mysql

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

vim /etc/profile

PATH=/data/mysql/bin:/data/mysql/lib:$PATH
export PATH

source /etc/profile

第十四步:修改mysql資料庫的位置
vim /etc/my.cnf
datadir = /data/mysql/mysqldb

第十五步:啟動mysql伺服器並加入開機自啟動

service mysqld start

chkconfig --level 35 mysqld on

第十六步:檢查mysql伺服器是否啟動

netstat -tunlp | grep 3306

第十七步:測試mysql登入
mysql -u root -p
密碼為空白,如果能登陸上,則安裝成功。

第十八步:修改mysql使用者root密碼

mysqladmin -u password ‘123456‘


第十九:如果出現以下錯解決辦法
mysqladmin: connect to server at ‘localhost‘ failed
error: ‘Access denied for user ‘root‘@‘localhost‘ (using password: YES)‘

解決辦法:

#> service mysqld stop
       #>mysqld_safe --skip-grant-tables &
       輸入 mysql -uroot -p 斷行符號進入
       >use mysql;
       > update user set password=PASSWORD("newpassword")where user="root";
       更改密碼為 newpassword
       > flush privileges; 更新許可權
       > quit 退出

操作已完成,如有問題,請及時跟我聯絡!

本文出自 “薰衣草的天空” 部落格,請務必保留此出處http://youlei.blog.51cto.com/2669714/1652957

Centos系統下面MySql資料庫源碼包編譯

聯繫我們

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