环境:yum install make gcc gcc-c++ libxml2 libxml2-devel libmcrypt libmcrypt-devel libtool-ltdl apr apr-* ncurses ncurses-*
安装mysql:
#tar -zxvf mysql-5.1.53.tar.gz
#cd mysql-5.1.53
#/usr/sbin/groupadd mysql
#/usr/sbin/useradd mysql -g mysql
#./configure --prefix=/opt/mysql --localstatedir=/opt/mysql/data/ --with-server-suffix=-enterprise-gpl --without-debug --with-big-tables --with-extra-charsets=gb2312,utf8,GBK --with-extra-charsets=all --with-pthread --enable-thread-safe-client --enable-static --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-innodb --without-ndb-debug --without-isam
#make(时间会很长、优化的比较多)
#make install
#mkdir –p /opt/mysql/data
#cd /opt/mysql
#bin/mysql_install_db --user=mysql
注:Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/opt/mysql/bin/mysqladmin -u root password 'new-password'
/opt/mysql/bin/mysqladmin -u root -h xsl228 password 'new-password'
Alternatively you can run:
/opt/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /opt/mysql ; /opt/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /opt/mysql/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /opt/mysql/bin/mysqlbug script!
#chown -R mysql.mysql .
#chown -R mysql.mysql /opt/mysql/data
#cp share/mysql/my-medium.cnf /etc/my.cnf
#cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld
#chmod 755 /etc/rc.d/init.d/mysqld
#/opt/mysql/bin/mysqld_safe --user=mysql &
如果mysql不成功,查看下mysql的错误日志
Mysql常见错误:
1.[Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
解决方式:#vi /etc/my.cnf 将skip-locking注释掉,然后添加一行:skip-external-locking
2. 110830 23:38:05 [ERROR] Aborting
110830 23:38:05 [Note] /opt/mysql/libexec/mysqld: Shutdown complete
110830 23:38:05 mysqld_safe mysqld from pid file /opt/mysql/data/xsl231.pid ended
110830 23:38:09 mysqld_safe Starting mysqld daemon with databases from /opt/mysql/data
/opt/mysql/libexec/mysqld: File './mysql-bin.index' not found (Errcode: 13)
解决方式:初始化的时候添加bin/mysql_install_db --user=mysql
启动的时候:/opt/mysql/bin/mysqld_safe --user=mysql &
(--with-server-suffix=-enterprise-gpl 给MySQL加个后缀名,在用mysql登录的时候在版本号的后面可以看到;
--without-debug
去除诊断模式,如果用--with-debug=full编译,大多数查询慢20%
--with-big-tables 大表支持
--with-extra-charsers=gbk,gb2312,utf8 设置支持gbk,gb2312,utf8字符集
--with-pthread 强制使用pthread库(posix线程库)
--enable-thread-safe-client 以线程方式编译客户端
--enable-static
--with-client-ldflags=-all-static
--with-mysqld-ldflags=-all-static
以静态方式编译客户端和服务端,能提高13%性能
--enable-assembler 使用一些字符函数来汇编版本
--without-ndb-debug 取消导航调试
--without-innodb
去掉innodb表支持,innodb是一种支持事务处理的表,适合企业级应用
--with-plugins=innobase 存储引擎,从mysql5.1开始,编译参加innodb插件就从
–with-innodb改成了—with-plugins=innobase)
![](http://img1.51cto.com/attachment/201108/163831412.jpg)