一:先安装依赖包(不然配置的时候会报错的!)
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>