一:先安裝依賴包(不然配置的時候會報錯的!)
1
<code>yum -y </code><code>install</code> <code>ncurses* libtermcap* gcc-c++*</code>
建立mysql使用者
2
<code>[root@HE1Packages]</code><code># groupadd mysql</code>
<code>[root@HE1Packages]</code><code># useradd -g mysql -s /sbin/nologin mysql</code>
二:擷取mysql源碼包
mysql官網下載下傳源碼即可
三:安裝mysql
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<code>[root@HE1 mysql]</code><code># tar xvf mysql-5.1.51.tar.gz</code>
<code>[root@HE1 mysql]</code><code># cd mysql-5.1.51</code>
<code>[root@HE1 mysql-5.1.51]</code><code># ./configure --prefix=/usr/local/mysql--localstatedir=/usr/local/mysql/data --enable-assembler --enable-local-infile--enable-thread-safe-client --with-big-tables --with-charset=utf8--with-extra-charsets=gbk,gb2312,utf8,ascii --with-readline --with-ssl--with-embedded-server --with-pthread --with-mysqld-user=mysql--with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static--with-plugins=partition,innobase,innodb_plugin >/home/mysql_setuplogs_configure.log2>&1</code>
<code>[root@HE1 mysql-5.1.51]</code><code># make > /home/mysql_setuplogs_make.log2>&1</code>
<code>[root@HE1 mysql-5.1.51]</code><code># make install > /home/mysql_setuplogs_makeinstall.log2>&1</code>
<code>[root@HE1 </code><code>local</code><code>]</code><code># chown -R mysql. /usr/local/mysql</code>
<code>[root@HE1 </code><code>local</code><code>]</code><code># echo "exportPATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib" >>/etc/profile</code>
<code>[root@HE1 ~]</code><code># source /etc/profile</code>
<code>[root@HE1 mysql-5.1.51]</code><code># cp support-files/my-medium.cnf/etc/my.cnf</code>
<code>[root@HE1 mysql-5.1.51]</code><code># cp support-files/mysql.server.sh/etc/init.d/mysql</code>
<code>[[email protected]]</code><code># chmod +x /etc/init.d/mysql</code>
<code>[root@HE1 bin]</code><code># mysql_install_db --user=mysql</code>
<code>[root@HE1 bin]</code><code># ./mysqld_safe --usermysql & (可以啟動但不能停止)</code>
<code>[root@HE1 bin]</code><code># mysqladmin -uroot password MANAGER</code>
<code>[root@HE1 bin]</code><code># mysqladmin -uroot -pMANAGER shutdown</code>
<code>[root@HE1 mysql]</code><code># cp/usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql</code>
<code>[root@HE1 init.d]</code><code># chmod 700 /etc/init.d/mysql</code>
<code>[root@HE1 init.d]</code><code># chkconfig --add mysql</code>
提示:configure支援的選項非常多,詳細的參數及說明建議參考官方文檔,也可以通過./configure --help檢視,這裡僅列出常用及推薦使用的選項。
--prefix=PREFIX:指定程式安裝路徑;
--enable-assembler:使用彙編模式;
--enable-local-infile:啟用對LOAD DATA LOCAL INFILE文法的支援(預設不支援);
--enable-profiling:Build a version with query profiling code (req.community-features)
--enable-thread-safe-client:使用編譯用戶端;
--with-big-tables:啟用32位平台對4G大表的支援;
--with-charset=CHARSET:指定字元集;
--with-collation=:預設collation;
--with-extra-charsets=CHARSET,CHARSET,...:指定附加的字元集;
--with-fast-mutexes:Compile with fast mutexes
--with-readline:
--with-ssl:啟用SSL的支援;
--with-server-suffix=:添加字元串到版本資訊;
--with-embedded-server:編譯embedded-server;
--with-pthread:強制使用pthread類庫;
--with-mysqld-user=:指定mysqld守護程序的使用者;
--with-mysqld-ldflags=:靜态編譯MySQL伺服器端;
--with-client-ldflags=:靜态編譯MySQL用戶端;
--with-plugins=PLUGIN,PLUGIN,...:MySQL伺服器端支援的元件(預設為空),可選值較多:
partition:MySQL Partitioning Support;
daemon_example:This is an example plugin daemon;
ftexample:Simple full-text parser plugin;
archive:Archive Storage Engine;
blackhole:Basic Write-only Read-never tables;
csv:Stores tables in text CSV format,強制安裝;
example:Example for Storage Engines for developers;
federated:Connects to tables on remote MySQL servers;
heap:Volatile memory based tables,強制安裝;
ibmdb2i:IBM DB2 for i Storage Engine;
innobase:Transactional Tables using InnoDB;
innodb_plugin:Transactional Tables using InnoDB;
myisam:Traditional non-transactional MySQL tables,強制安裝;
myisammrg:Merge multiple MySQL tables into one,強制安裝;
ndbcluster:High Availability Clustered tables;
--with-plugin-PLUGIN:強制指定的插件連結至MySQL伺服器;
--with-zlib-dir=:向MySQL提供一個自定義的壓縮類庫位址;
--without-server:僅安裝MySQL用戶端;
--without-query-cache:不要編譯查詢緩存;
--without-geometry:不要編譯geometry-related部分;
--without-debug:編譯為産品版,放棄debugging代碼;
--without-ndb-debug:禁用special ndb debug特性;
提示:執行Configure時如果報bin/rm: cannot remove `libtoolt': No such file or directory錯誤,可按照下列步驟解決:
1、确認libtool是否已經安裝,如果沒有安裝的話,則先安裝libtool
# rpm -qa | grep libtool
# yum -y install libtool
2、分别執行以下三條指令:
# autoreconf --force --install
# libtoolize --automake --force
# automake --force --add-missing
再重新編譯安裝,問題解決!
CentOS6.5中編譯是遇見如下錯誤
error: No curses/termcap library found
checking fortgetent in -lncurses... no
checking fortgetent in -lcurses... no
checking fortgetent in -ltermcap... no
checking fortgetent in -ltinfo... no
checking fortermcap functions library... configure: error: No curses/termcap library found
安裝之初我已經用yum安裝了ncurses*了,不過rpm -qa發現缺少了
ncurses-devel
rpm -ivh 安裝即可 ncurses-devel-5.7-3.20090208.el6.x86_64
gcc-c++
[[email protected]]# rpm -qa|grep ncurses
ncurses-base-5.7-3.20090208.el6.x86_64
ncurses-5.7-3.20090208.el6.x86_64
ncurses-devel-5.7-3.20090208.el6.x86_64
ncurses-libs-5.7-3.20090208.el6.x86_64
[[email protected]]# rpm -qa|grep gcc
gcc-4.4.7-4.el6.x86_64
libgcc-4.4.7-4.el6.x86_64
gcc-c++-4.4.7-4.el6.x86_64
<b> 本文轉自 dbapower 51CTO部落格,原文連結:http://blog.51cto.com/suifu/1742483</b><b>,如需轉載請自行聯系原作者</b>