mysql5.5.17源碼安裝,mysql5.5.17源碼

來源:互聯網
上載者:User

mysql5.5.17源碼安裝,mysql5.5.17源碼
1. 源碼包下載 
源碼包通常也採用tar.gz壓縮,名稱中只包含版本資訊,大小也比RPM包、二進位包小很多,解壓後的檔案中含有INSTALL-SOURCE檔案,可從MySQL官網(http://www.mysql.com/downloads/)下載,如:mysql-5.5.17.tar.gz
2. CMake
在採用源碼包安裝MySQL執行個體之前,先來介紹一下cmake這個編譯工具。在MySQL 5.5之前,是採用configure工具執行源碼編譯的,到了MySQL 5.5,改用cmake進行編譯。這是一個比make更進階的編譯組態工具,可根據不同平台、不同編譯器,生產相應的Makefile或者vcproj項目,所以需要首先從官網(http://www.cmake.org)下載cmake工具並安裝之。
安裝cmake之前安裝gcc包
rpm -ivh kernel-headers-2.6.18-308.el5.x86_64.rpm
rpm -ivh glibc-headers-2.5-81.x86_64.rpm
rpm -ivh glibc-devel-2.5-81.x86_64.rpm
rpm -ivh gcc-4.1.2-52.el5.x86_64.rpm
rpm -ivh libstdc++-devel-4.1.2-52.el5.x86_64.rpm
rpm -ivh gcc-c++-4.1.2-52.el5.x86_64.rpm
安裝cmake
/mysql/cmake-2.8.3
./configure
gmake && make install
 
 
3. 安裝mysql 5.5.17
1. 建立mysql系統組及使用者
 groupadd mysql
 useradd –g mysql mysql
 
2. 設定使用者作業系統資源限制
 
vi /etc/security/limits.conf
        mysql    soft    nproc    2047
        mysql    hard    nproc    16384
        mysql    soft    nofile    1024
        mysql    hard    nofile    65536
安裝需要包
# rpm -ivh ncurses-devel-5.5-24.20060715.x86_64.rpm
# rpm -ivh bison-2.3-2.1.x86_64.rpm
 
 
3. 安裝MYSQL Server
#mkdir /opt/mysql
#chown -R mysql:mysql /opt/mysql
#gunzip mysql-5.5.17.tar.gz
#tar xvf mysql-5.5.17.tar
#cd mysql-5.5.17
        # cmake  -DCMAKE_INSTALL_PREFIX=/opt/mysql \
        > -DMYSQL_USER=mysql \
        > -DMYSQL_TCP_PORT=3306 \
        > -DMYSQL_DATADIR=/opt/mysql/data \
        > -DWITH_MYISAM_STORAGE_ENGINE=1 \
        > -DWITH_INNOBASE_STORAGE_ENGINE=1 \
        > -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
        > -DWITH_MEMORY_STORAGE_ENGINE=1 \
        > -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
        > -DWITH_PARTITION_STORAGE_ENGINE=1 \
        > -DENABLED_LOCAL_INFILE=1 \
        > -DWITH_READLINE=1 \
        > -DWITH_SSL=yes \
        > -DDEFAULT_CHARSET=utf8 \
        > -DDEFAULT_COLLATION=utf8_general_ci \
        > -DEXTRA_CHARSETS=all
         
        #make
        #make install
         
        初始化DB
        # sh scripts/mysql_install_db --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data
        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:
         
        /opt/mysql/bin/mysqladmin -u root password 'new-password'
        /opt/mysql/bin/mysqladmin -u root -h mysql password 'new-password'
         
        Alternatively you can run:
        /opt/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 /opt/mysql ; /opt/mysql/bin/mysqld_safe &
         
        You can test the MySQL daemon with mysql-test-run.pl
        cd /opt/mysql/mysql-test ; perl mysql-test-run.pl
         
        Please report any problems with the /opt/mysql/scripts/mysqlbug script!
 
 
 
4. 啟動Mysql Sever
配置service服務
# cp /opt/mysql/files/mysql.server  /etc/init.d/mysql   --配置basedir、datadir
配置mysql參數檔案my.cnf
 
 
#vi /etc/my.cnf
[client]
#password       = your_password
port            = 3306
socket          = /opt/mysql/data/mysql.sock
 
[mysqld]
port            = 3306
server-id       = 24
datadir         = /opt/mysql/data
socket          = /opt/mysql/data/mysql.sock
pid-file        = /opt/mysql/data/mysql.pid
character-set-server   = utf8
default_storage_engine = InnoDB
log-bin          = /opt/mysql/data/mysql-bin
binlog_format    = row
sync-binlog      = 1
slow-query-log      = on
slow-query-log-file = /opt/mysql/data/mysql-slow.log
log_error        = /opt/mysql/data/mysql.err
max_connections         = 2000
back_log                = 50
skip-external-locking
skip-name-resolve
 
key_buffer_size         = 256M
max_allowed_packet      = 1M
table_open_cache        = 2000
sort_buffer_size        = 1M
read_buffer_size        = 1M
read_rnd_buffer_size    = 4M
myisam_sort_buffer_size = 64M
thread_cache_size       = 8
query_cache_size        = 16M
thread_concurrency      = 8
 
innodb_data_home_dir      = /opt/mysql/data
innodb_data_file_path     = ibdata1:10M:autoextend
innodb_log_group_home_dir = /opt/mysql/data
innodb_buffer_pool_size         = 256M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size            = 64M
innodb_log_buffer_size          = 8M
innodb_flush_log_at_trx_commit  = 1
innodb_lock_wait_timeout        = 50
 
[mysqldump]
quick
max_allowed_packet = 16M
 
[mysql]
no-auto-rehash
#safe-updates
 
[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
 
[mysqlhotcopy]
interactive-timeout
 
"/etc/my.cnf" [New] 62L, 1531C written
[root@mysql support-files]# more /etc/my.cnf 
[client]
#password       = your_password
port            = 3306
socket          = /opt/data/mysql.sock
 
[mysqld]
port            = 3306 
server-id       = 24
datadir         = /opt/mysql/data
socket          = /opt/mysql/data/mysql.sock
pid-file        = /opt/mysql/data/mysql.pid
character-set-server   = utf8
default_storage_engine = InnoDB
log-bin          = /opt/mysql/data/mysql-bin
binlog_format    = row
sync-binlog      = 1 
slow-query-log      = on
slow-query-log-file = /opt/mysql/data/mysql-slow.log
log_error        = /opt/mysql/data/mysql.err
max_connections         = 2000
back_log                = 50
skip-external-locking
skip-name-resolve
 
key_buffer_size         = 256M
max_allowed_packet      = 1M
table_open_cache        = 2000
sort_buffer_size        = 1M
read_buffer_size        = 1M
read_rnd_buffer_size    = 4M
myisam_sort_buffer_size = 64M
thread_cache_size       = 8
query_cache_size        = 16M
thread_concurrency      = 8 
 
innodb_data_home_dir      = /opt/mysql/data
innodb_data_file_path     = ibdata1:10M:autoextend
innodb_log_group_home_dir = /opt/mysql/data
innodb_buffer_pool_size         = 256M
innodb_additional_mem_pool_size = 20M
innodb_log_file_size            = 64M
innodb_log_buffer_size          = 8M
innodb_flush_log_at_trx_commit  = 1
innodb_lock_wait_timeout        = 50
 
[mysqldump]
quick
max_allowed_packet = 16M
 
[mysql]
no-auto-rehash
#safe-updates
 
[myisamchk]
key_buffer_size = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M
 
[mysqlhotcopy]
interactive-timeout
 
 
# service mysql start
Starting MySQL....[  OK  ]
官方怎下載mysql源碼包?

downloads.mysql.com/...=other

Source and other files5.6.10
x86 (23 Jan 2013, 275.7M)SignatureMD5: ccecf1e1843a0165f7b67bc5bfc0b145
ZIP format (23 Jan 2013, 40.9M)SignatureMD5: 861e49d3096a1c98f7abd083a65778b6
x86, 64-bit (23 Jan 2013, 283.5M)SignatureMD5: b8f70c35e50cf49a4c8ed01d731b7d64
mysql-5.6.10.tar.gz (23 Jan 2013, 33.5M)SignatureMD5: 9dcee911fb4bc7e977a6b63f4d3ffa63

裡面有這些
直接點擊 mysql-5.6.10.tar.gz
或者 你找其他的版本...

採納給分哦..
 
目前最新版的mysql在Linux下源碼編譯安裝的方法具體參數的含義一併說明

有話好說,以下是CentOS Linux 5的配置經驗:
添加mysql帳號
groupadd mysql
useradd -r -g mysql mysql
編譯必需先安裝
cmake-2.8.4 和 bison-2.4.3
安裝成功後解壓mysql-5.5.15.tar.gz:
在源碼根目錄開啟終端輸入以下配置參數並斷行符號
cmake -DCMAKE_INSTALL_PREFIX=/etc/mysql \
-DMYSQL_UNIX_ADDR=/etc/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/var/mysql/data \
-DMYSQL_USER=mysql

成功執行以下命令後在最後會見到 (/root/Desktop/是你的源碼目錄,視你的情況定)
-- Build files have been written to: /root/Desktop/mysql-5.5.15

運行make安裝:
make
make install
以下步驟就不一一解說了:
cd /mysql/mysql
chown -R mysql:mysql .
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
cp ./support-files/my-small.cnf ./my.cnf
cp support-files/mysql.server mysql; chmod +x mysql
chown -R mysql:root .
./mysql start
./bin/mysqladmin -u root -p 123456

添加開機啟動服務
chkconfig --add mysql
chkconfig mysql on
service mysql start

順利的話到這裡完成了,祝你成功。
 

相關文章

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.