編譯安裝mysql
groupadd mysql
useradd -g mysql mysql
MYSQLFILE="mysql-5.1.24-rc.tar.gz"
tar -zvxf $MYSQLFILE
cd mysql-5.1.24-rc
'./configure' \
'--prefix=/usr/local/mysql' \
'--with-charset=utf8' \
'--with-extra-charsets=latin1,gbk,gb2312,ascii,big5'
make
make install
cp support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .
bin/mysql_install_db --user=mysql
chown -R root .
chown -R mysql var
#到此處已安裝完成。可啟動mysql:/usr/local/mysql/bin/mysqld_safe --user=mysql &
#關閉mysql:/usr/local/mysql/bin/mysqladmin -p shutdown
# 如下為添加mysql至服務
cp mysql-5.1.24-rc/support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 775 /etc/rc.d/init.d/mysqld chkconfig –add mysqld 然後啟動即可--service mysqld start 自啟動:chkconfig --level 35 mysqld on
添加至環境變量:
vi /etc/profile
LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/usr/local/mysql/lib
export LD_LIBRARY_PATH
PATH=$PATH:.:/usr/local/mysql/bin
export PATH
編譯安裝出現如下錯誤
checking whether make sets $(MAKE)... yes
checking "character sets"... default: utf8, collation: utf8_general_ci; compiled in: utf8 latin1 utf8 latin1 gbk gb2312 ascii big5
checking whether to compile national Unicode collations... yes
checking for doxygen... no
checking for pdflatex... no
checking for makeindex... no
checking whether build environment is sane... yes
checking whether make sets $(MAKE)... (cached) yes
checking for gawk... (cached) gawk
checking for gcc... no
checking for cc... no
checking for cc... no
checking for cl... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.The solution is simple, run one of the following commands to install a C compiler:
未安裝c語言編譯環境!
解決辦法:
CentOS: yum -y install gcc
Fedora: up2date -i gcc
./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-extra-charsets=latin1,gbk,gb2312,ascii,big5
make[1]: Entering directory `/usr/local/software/tools/mysql-5.1.52/mysys'
source='my_new.cc' object='my_new.o' libtool=no
DEPDIR=.deps depmode=none /bin/sh ../depcomp
g++ -DDEFAULT_BASEDIR="/usr/local/mysql" -DMYSQL_DATADIR=""/usr/local/mysql/var"" -
DDEFAULT_CHARSET_HOME=""/usr/local/mysql"" -DSHAREDIR=""/usr/local/mysql/share/mysql"" -DDEFAULT_HOME_ENV=MYSQL_HOME -
DDEFAULT_GROUP_SUFFIX_ENV=MYSQL_GROUP_SUFFIX -DDEFAULT_SYSCONFDIR=""/usr/local/mysql/etc"" -DHAVE_CONFIG_H -I. -I../include
-I../include -I../include -I. -O -fno-implicit-templates -fno-exceptions -fno-rtti -c -o my_new.o my_new.cc
../depcomp: line 571: exec: g++: not found
make[1]: *** [my_new.o] Error 127
make[1]: Leaving directory `/usr/local/software/tools/mysql-5.1.52/mysys'
make: *** [all-recursive] Error 1
../depcomp: line 571: exec: g++: not found 提示這個是缺少:gcc-c++-3.4.6-3.i386.rpm
yum -y install gcc-c
3../include/my_global.h:909: error: redeclaration of C++ built-in type `bool'
make[2]: *** [my_new.o] Error 1
make[2]: Leaving directory `/home/tools/mysql-5.0.22/mysys'
make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/usr/local/mysql-5.1' make: *** [all] Error 2
yum -y install ncurses-devel
根據提示安裝累得半死,後來直接找到依賴包全部安裝就好了!
依賴的開發包安裝
yum -y install gcc glib gcc-c++ esound-devel ncurses-devel