這篇文章主要為大家展示了“Linux下如何安裝配置源代碼版本的MySQL”,內(nèi)容簡(jiǎn)而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“Linux下如何安裝配置源代碼版本的MySQL”這篇文章吧。
專注于為中小企業(yè)提供成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)鄄城免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了成百上千家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
操作系統(tǒng)版本:Red Hat Enterprise Linux Server release 5 (Tikanga)
MySQL版本:
安裝文件:MySQL-community-5.1.45-1.rhel5.src.rpm
1.釋放源代碼包
使用的安裝文件是一個(gè)source RPM,首先要將其內(nèi)容釋放:
方法一:
[root@redhat5-db-1 software]# rpm -i MySQL-community-5.1.45-1.rhel5.src.rpm
error: cannot create %sourcedir /usr/src/redhat/SOURCES
[root@redhat5-db-1 software]# mkdir -p /usr/src/redhat/SOURCES
[root@redhat5-db-1 software]# rpm -i MySQL-community-5.1.45-1.rhel5.src.rpm
warning: user mysqldev does not exist - using root
warning: group mysqldev does not exist - using root
warning: user mysqldev does not exist - using root
warning: group mysqldev does not exist - using root
[root@redhat5-db-1 software]# ls /usr/src/redhat/*
/usr/src/redhat/SOURCES:
mysql-5.1.45.tar.gz
/usr/src/redhat/SPECS:
mysql-5.1.45.rhel5.spec
[@more@]方法二:
[root@redhat5-db-1 software]# rpm2cpio MySQL-community-5.1.45-1.rhel5.src.rpm | cpio -idmv
mysql-5.1.45.rhel5.spec
mysql-5.1.45.tar.gz
43995 blocks
[root@redhat5-db-1 software]# ls
mysql-5.1.45.rhel5.spec mysql-5.1.45.tar.gz MySQL-community-5.1.45-1.rhel5.src.rpm
注:無(wú)論使用哪種方法,都會(huì)在釋放源代碼包的同時(shí),釋放另一個(gè)文件 mysql-5.1.45.rhel5.spec 。它是一個(gè)RPM SPEC文件,可以通過(guò)rpmbuild命令創(chuàng)建MySQL的源代碼文件或二進(jìn)制程序(-bp選項(xiàng)在 /usr/src/redhat/BUILD 目錄下創(chuàng)建源代碼文件,-bb選項(xiàng)在 /usr/src/redhat/RPM 目錄下創(chuàng)建二進(jìn)制程序),這里不再贅述。
2.安裝前的準(zhǔn)備工作
1)創(chuàng)建用戶和組
[root@redhat5-db-1 software]# groupadd mysql
[root@redhat5-db-1 software]# useradd -g mysql mysql
[root@redhat5-db-1 software]# id mysql
uid=502(mysql) gid=504(mysql) groups=504(mysql)
2)準(zhǔn)備必要的目錄
[root@redhat5-db-1 software]# mkdir -p /opt/mysql /data/mysql
[root@redhat5-db-1 software]# chown mysql:mysql /opt/mysql /data/mysql
3)安裝必要的RPM
需要安裝ncurses-devel,否則編譯時(shí)會(huì)報(bào)如下錯(cuò)誤:
checking for termcap functions library... configure: error: No curses/termcap library found
在Red Hat EL 5安裝光盤(pán)中找到該RPM,進(jìn)行安裝:
[root@redhat5-db-1 software]# mount -o ro /dev/cdrom /mnt/cdrom
[root@redhat5-db-1 software]# rpm -ivh /mnt/cdrom/Server/ncurses-devel-5.5-24.20060715.i386.rpm
warning: /mnt/cdrom/Server/ncurses-devel-5.5-24.20060715.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:ncurses-devel ########################################### [100%]
4)解壓源代碼包
[root@redhat5-db-1 software]# tar -zxf mysql-5.1.45.tar.gz
[root@redhat5-db-1 software]# ls -p
mysql-5.1.45/ mysql-5.1.45.rhel5.spec mysql-5.1.45.tar.gz MySQL-community-5.1.45-1.rhel5.src.rpm
3.安裝MySQL
1)CONFIGURE
[root@redhat5-db-1 software]# su - mysql
[mysql@redhat5-db-1 ~]$ cd /opt/software/mysql-5.1.45
[mysql@redhat5-db-1 mysql-5.1.45]$ ./configure --prefix=/opt/mysql --localstatedir=/data/mysql --with-plugins=innobase
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
......
config.status: executing depfiles commands
config.status: executing libtool commands
/bin/rm: cannot remove `libtoolT': No such file or directory
config.status: executing default commands
Thank you for choosing MySQL!
Remember to check the platform specific part of the reference manual
for hints about installing MySQL on your platform.
Also have a look at the files in the Docs directory.
注:--prefix選項(xiàng)指定MySQL程序的路徑;--localstatedir選項(xiàng)指定MySQL數(shù)據(jù)文件的路徑;--with-plugins=innobase 指定MySQL服務(wù)器包含InnoDB功能。
2)MAKE
[mysql@redhat5-db-1 mysql-5.1.45]$ make
Making all in .
make[1]: Entering directory `/opt/software/mysql-5.1.45'
make abi_headers="include/mysql/plugin.h include/mysql.h" do_abi_check
make[2]: Entering directory `/opt/software/mysql-5.1.45'
......
Making all in win
make[1]: Entering directory `/opt/software/mysql-5.1.45/win'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/opt/software/mysql-5.1.45/win'
3)MAKE-INSTALL
[mysql@redhat5-db-1 mysql-5.1.45]$ make install
Making install in .
make[1]: Entering directory `/opt/software/mysql-5.1.45'
make abi_headers="include/mysql/plugin.h include/mysql.h" do_abi_check
make[2]: Entering directory `/opt/software/mysql-5.1.45'
......
Making install in win
make[1]: Entering directory `/opt/software/mysql-5.1.45/win'
make[2]: Entering directory `/opt/software/mysql-5.1.45/win'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/opt/software/mysql-5.1.45/win'
make[1]: Leaving directory `/opt/software/mysql-5.1.45/win'
[mysql@redhat5-db-1 mysql-5.1.45]$ ls /opt/mysql
bin docs include lib libexec mysql-test share sql-bench
4.安裝后的工作
1)創(chuàng)建選項(xiàng)文件
[root@redhat5-db-1 ~]# cp /opt/software/mysql-5.1.45/support-files/my-medium.cnf /etc/my.cnf
[root@redhat5-db-1 ~]# chown mysql:mysql /etc/my.cnf
可以通過(guò)修改其內(nèi)容對(duì)MySQL服務(wù)器進(jìn)行配置。這里只簡(jiǎn)單取消InnoDB相關(guān)參數(shù)所在行的注釋:
# Uncomment the following if you are using InnoDB tables
innodb_data_home_dir = /data/mysql/
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /data/mysql/
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
2)設(shè)置環(huán)境變量
在mysql的HOME目錄下的.bash_profile文件中添加如下內(nèi)容:
# Added by ggyy on March 31st, 2010
PATH=$PATH:/opt/mysql/bin
export PATH
3)初始化MySQL
[mysql@redhat5-db-1 ~]$ /opt/mysql/bin/mysql_install_db
Installing MySQL system tables...
100331 18:21:59 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
Filling help tables...
100331 18:22:00 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
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 redhat5-db-1 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/bin/mysqlbug script!
[mysql@redhat5-db-1 ~]$ ls /data/mysql
mysql mysql-bin.000001 mysql-bin.000002 mysql-bin.index test
3)啟動(dòng)和關(guān)閉MySQL
啟動(dòng)MySQL服務(wù)器,測(cè)試登陸:
[mysql@redhat5-db-1 ~]$ /opt/mysql/bin/mysqld_safe &
[1] 3028
[mysql@redhat5-db-1 ~]$ 100331 18:27:18 mysqld_safe Logging to '/data/mysql/redhat5-db-1.err'.
100331 18:27:18 mysqld_safe Starting mysqld daemon with databases from /data/mysql
mysql> select version();
+------------+
| version() |
+------------+
| 5.1.45-log |
+------------+
1 row in set (0.00 sec)
mysql> show variables like "have_innodb";
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| have_innodb | YES |
+---------------+-------+
1 row in set (0.00 sec)
可以使用mysql.server腳本啟動(dòng)和關(guān)閉MySQL服務(wù)器,它位于解壓的源代碼目錄下的support-files子目錄中。該目錄下還有許多其它有用的文件、腳本,可以考慮將其復(fù)制到MySQL程序目錄下,并在.bash_profile文件里的PATH中添加相應(yīng)路徑。
[mysql@redhat5-db-1 ~]$ cp -pr /opt/software/mysql-5.1.45/support-files /opt/mysql
[mysql@redhat5-db-1 ~]$ chmod u+x /opt/mysql/support-files/mysql.server
[mysql@redhat5-db-1 ~]$ which mysql.server
/opt/mysql/support-files/mysql.server
[mysql@redhat5-db-1 ~]$ mysql.server stop
Shutting down MySQL.100331 18:58:49 mysqld_safe mysqld from pid file /data/mysql/redhat5-db-1.pid ended
[ OK ]
以上是“Linux下如何安裝配置源代碼版本的MySQL”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
網(wǎng)站題目:Linux下如何安裝配置源代碼版本的MySQL
網(wǎng)站鏈接:http://www.chinadenli.net/article38/jdjdpp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、電子商務(wù)、品牌網(wǎng)站設(shè)計(jì)、ChatGPT、自適應(yīng)網(wǎng)站、網(wǎng)站內(nèi)鏈
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)