下载地址:http://mysql.ntu.edu.tw/Downloads/Mysql-5.1/mysql-5.1.62.tar.gz

编译安装:

安装环境:CentOS X64 6.0 最小化安装的系统

依赖软件包:yum install gcc* ncurses-devel.x86_64 automake autoconf -y

先增加用户组:

groupadd mysql

useradd -s /sbin/nologin -g mysql -M mysql

./configure --prefix=/usr/local/mysql 

--with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock    #指定Mysql socket文件存放路径

--localstatedir=/usr/local/mysql/data            #设定Mysql的数据文件存放位置

--enable-assembler                     #允许使用汇编模式(优化性能)

--enable-thread-safe-client                  #以线程方式编译客户端

--with-mysqld-user=mysql

--with-big-tables                                                                  #支持超过4G的大表

--without-debug                        #使用非debug模式

--with-pthread                         #强制使用pthread库程序编译

--enable-assembler

--with-extra-charsets=complex

--with-readline

--with-ssl

--with-embedded-server

--enable-local-infile

--with-plugins=partition,innobase

--with-plugin-PLUGIN

--with-mysqld-ldflags=-all-static                #服务器使用静态库(优化性能)

--with-client-ldflags=-all-static                 #客户端使用静态库(优化性能)

(方便复制:./configure --prefix=/usr/local/mysql --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock  --localstatedir=/usr/local/mysql/data --enable-assembler --enable-thread-safe-client --with-mysqld-user=mysql --with-big-tables --without-debug --with-pthread --with-extra-charsets=complex --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase --with-plugin-PLUGIN --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static )

make

make install

mysql的配置文件在源文件目录的support-files目录下

cp my-small.cnf /etc/my.cnf

创建数据库文件夹 mkdir /usr/local/mysql/data  

授权mysql用户访问mysql的安装目录 chown -R mysql /usr/local/mysql

安装mysql数据库文件初始化数据库 /usr/local/mysql/bin/mysql_install_db --user=mysql

启动数据库 /usr/local/mysql/bin/mysqld_safe & (当系统安装过mysql的时候就不能这样启动了 一定要先指定数据库的目录 /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data/ &)

或者把mysql的启动脚本复制到安装目录下的bin下 和 /etc/init.d/mysql  都行

cp  support-files/mysql.server /usr/local/mysql/bin/   chmod 700 /usr/local/mysql/bin/mysql.server(这时候是没有密码的)

日志在 /usr/local/mysql/data .err结尾的文件

设置mysql开机自动启动:

cp support-files/mysql.server /etc/init.d/mysqld

chkconfig --add mysqld

chkconfig mysqld on

放/etc/rc.local也可以

设置mysql root密码 /usr/local/mysql/bin/mysqladmin -uroot password '密码'

查看用户:select user,host from mysql.user 删除用户:drop user ""@localhost;

查看mysql的版本  select version();