编译安装mysql 5.141源代码,常见两处错误解决

作者:admin,2009年十二月14日 9:37 上午,分类:mysql

first u must add users for mysql account and group form mysqld

1 groupadd mysql

useradd -g mysql mysql
2 wget source code
http://dev.mysql.com/downloads/mysql/5.1.html 可以到此页面找到最下面
wget
如果是zip 文件 unzip mysql-1.41.zip
或者tar -xzvf mysql-5.1.41.tar.gz  cd mysql-5.1.41
编译安装可以优化许多参数,如静态编译,去掉自己不用字符集,如果不用innodb 也可以去掉。根据自己的环境及需要使用的option
量身打造mysql编译安装参数,据说有些选项可以调高mysql的性能。
./configure --prefix=/usr/local/mysql/ --with-comment=Source
 --with-server-suffix=liufb--without-debug --with-charset=utf8
--with-extra-charsets=latin1,gbk --enable-thread-safe-client
 --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static
 --with-mysqld-libs=-all-static --enable-assembler
--without-innodb --with-unix-socket-path=/usr/local/mysql/sock/mysql.sock
如果出现checking for termcap functions library… configure: error: No curses/termcap library found 错误,安装ncurses就可以解决
如果是在debian或者ubuntu下这可以直接:aptitude install libncurses5-dev
或者手工编译下载安装,方法可以google下
编译 安装
# make &&  install
 cd /usr/local/mysql
 scripts/mysql_install_db --user=mysql
如果出现错误:
FATAL ERROR: Could not find mysqld
The following directories were searched:
        /usr/libexec
        /usr/sbin
        /usr/bin
是因为原来装有/etc/mysql/my.cnf引起的。将/etc/mysql/my.cnf删除
 chown -R root  /usr/local/mysql;
 chown -R mysql /usr/local/mysql/var;
 chgrp -R mysql /usr/local/mysql
 cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
 /usr/local/mysql/bin/mysqladmin -u root password '123456'

直接启动:/usr/local/mysql/share/mysql/mysql.server start
/usr/local/mysql/share/mysql/mysql.server stop
或者:
把mysql/bin添加到$PATH变量中:
export PATH=/usr/local/mysql/bin/:$PATH
/etc/init.d/mysqld start
mysql -u root -p12346

发表评论