我下的是5.1.47的源码。
这是从网上以及书上找到的一段配置:
./configure --prefix=/usr/local/mysql --datadir=/data/mysqldata --without-debug --without-bench --enable-thread-safe-client --enable-assembler --enable-profiling --with-partition --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-charset=latin1 --with-extra-charset=utf8,gbk --with-innodb --with-csv-storage-engine --with-federated-storage-engine --with-mysqld-user=mysql --without-embedded-server --with-server-suffix=-community --with-unix-socket-path=/usr/local/mysql/sock/mysql.sock
在实际执行时,产生错误提示有些库文件找不到。检查了下,发现有些库并没有对应的静态库文件,此时还用-all-static 这个参数来编译,就会提示找不到。比如说今天碰到的ncursesw,make的时候它就提示not find -lncursesw 找了下,只有libncursesw.so,于是用./configure的参数 --with-named-curses-libs=/usr/lib64/libncursesw.so结果又提示需要静态类库,动态的不行。我找了下,确实找不到libncursesw.a文件。我想,大概make的时候,mysql的安装程序会去找libncursesw.a文件,找不到才会报这个错的。于是只能去掉这个参数:--with-client-ldflags=-all-static
另外,我为了偷懒,将下载mysql-version.tar.gz解压到/usr/local后得到mysql-version,我直接将这个文件夹重命名成mysql,然后直接进入这个目录/usr/local/mysql进行./configure和make&make install,然后就一直不断的报错。
郁闷得不行之后,还是老老实实按照mysql文档上说的来 ,安装文件与安装到的目标文件夹分开,不重用一个。
并且./configure也需要修改:首先需要在./configure前加一段,另外,该版本默认是不安装innodb的,必须加上参数,并且参数的格式还和以前不一样了。结合官方文档中的说明,最终改成这样:
CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --datadir=/data/mysqldata --without-debug --enable-thread-safe-client --enable-assembler --enable-profiling --with-mysqld-ldflags=-all-static --with-charset=latin1 --with-extra-charsets=utf8,gbk --with-mysqld-user=mysql --without-embedded-server --with-server-suffix=-community --with-unix-socket-path=/usr/local/mysql/sock/mysql.sock --with-plugins=innobase,partition
然后再make ,再make install。总之都按官方文档上的来,最后,终于,mysql装好了!
在修改my.cnf中一些innodb 的优化选项后,重启Mysql,启不来了!
查看日志:100611 22:41:18 InnoDB: Operating system error number 2 in a file operation.
InnoDB: The error means the system cannot find the path specified.
InnoDB: If you are installing InnoDB, remember that you must create
InnoDB: directories yourself, InnoDB does not create them.
InnoDB: File name /data/mysql/innodb_data/ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
100611 22:41:18 mysqld_safe mysqld from pid file /usr/local/mysql/var/Tencent64.pid ended
明白了,innodb不会自己创建目录!由于我将innodb的data设为了/data/mysql/innodb_data/,而我又没有创建这些目录,并且innodb也会自己创建,于是启动失败。
于是手动创建之。
/usr/local/mysql/bin/mysqld_safe &
启动好了!
进入mysql ,show plugins,终于看到亲爱的Innodb!
附上官方文档:
如果你使用的gcc版本足够新,可以识别-fno-exceptions选项,则使用该选项非常重要。否则,你编译二进制时出现问题。我们建议你同时使用-felide-constructors和-fno-rtti选项。当有疑问时,执行下面操作:CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors \-fno-exceptions -fno-rtti" ./configure \--prefix=/usr/local/mysql --enable-assembler \--with-mysqld-ldflags=-all-static
在大多数系统中,可以得到快速、稳定的二进制。
你必须执行的安装MySQL源码分发版的基本命令是:shell> groupadd mysqlshell> useradd -g mysql mysqlshell> gunzip < mysql-VERSION.tar.gz | tar -xvf -shell> cd mysql-VERSIONshell> ./configure --prefix=/usr/local/mysqlshell> makeshell> make installshell> cp support-files/my-medium.cnf /etc/my.cnfshell> cd /usr/local/mysqlshell> bin/mysql_install_db --user=mysqlshell> chown -R root .shell> chown -R mysql varshell> chgrp -R mysql .shell> bin/mysqld_safe --user=mysql &