使用cmake編譯安裝MySQL 5.5

來源:互聯網
上載者:User

使用cmake編譯安裝MySQL 5.5

首先將cmake-2.8.8.tar.gz、mysql-5.5.32.tar.gz源碼包上傳至伺服器。

解壓並安裝cmake

[root@localhost ~]# tar -zxvf cmake-2.8.8.tar.gz
[root@localhost ~]# cd cmake-2.8.8
[root@localhost cmake-2.8.8]# ./configure
......
-- Configuring done
-- Generating done
-- Build files have been written to: /root/cmake-2.8.8
---------------------------------------------
CMake has bootstrapped.  Now run gmake.

確保cmake沒有錯誤發生

[root@localhost cmake-2.8.8]# echo $?
0

下面運行gmake命令
[root@localhost cmake-2.8.8]# gmake
[root@localhost cmake-2.8.8]# gmake install

3. 安裝MySQL依賴表ncurses-devel

[root@localhost cmake-2.8.8]# yum install ncurses-devel -y

4. 建立mysql使用者

[root@localhost cmake-2.8.8]# groupadd mysql
       
[root@localhost cmake-2.8.8]# useradd mysql -s /sbin/nologin -M -g mysql

5. 解壓編譯MySQL

[root@localhost ~]# cd ..
[root@localhost ~]# tar -zxvf mysql-5.5.32.tar.gz
[root@localhost ~]# cd mysql-5.5.32
[root@localhost mysql-5.5.32]#  cmake -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \
  -DMYSQL_DATADIR=/application/mysql-5.5.32/data \
  -DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/tmp/mysql.sock \
  -DDEFAULT_CHARSET=utf8 \
  -DDEFAULT_COLLATION=utf8_general_ci \
  -DWITH_EXTRA_CHARSETS=all \
  -DWITH_INNOBASE_STORAGE_ENGINE=1 \
  -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
  -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
  -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
  -DWITH_SSL=yes  \
  -DENABLED_LOCAL_INFILE=1

[root@localhost mysql-5.5.32]# make && make install

為安裝目錄做一個link

[root@localhost mysql-5.5.32]# ln -s /application/mysql-5.5.32/ /application/mysql

將原始碼目錄中的設定檔copy到/etc目錄下

[root@localhost mysql-5.5.32]# cp support-files/my-small.cnf /etc/my.cnf

6. 配置環境變數

1 [root@localhost mysql-5.5.32]# echo 'export PATH=/application/mysql/bin:$PATH' >> /etc/profile

7. 授權mysql使用者訪問安裝目錄

[root@localhost mysql]# chown mysql.mysql -R /application/mysql

8. 初始化mysql資料庫

[root@localhost scripts]# ./mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql
Installing MySQL system tables...
OK
Filling help tables...
OK
 
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:
 
/application/mysql/bin/mysqladmin -u root password 'new-password'
/application/mysql/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
 
Alternatively you can run:
/application/mysql/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 /application/mysql ; /application/mysql/bin/mysqld_safe &
 
You can test the MySQL daemon with mysql-test-run.pl
cd /application/mysql/mysql-test ; perl mysql-test-run.pl
 
Please report any problems with the /application/mysql/scripts/mysqlbug script!

9. 製作mysql啟動指令碼

[root@localhost mysql-5.5.32]# cp support-files/mysql.server /etc/init.d/mysqld

10 啟動mysql

[root@localhost mysql-5.5.32]# /etc/init.d/mysqld start
Starting MySQL..       

基於Cmake編譯安裝MySQL 5.5       

本文永久更新連結地址:

聯繫我們

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