一。下载:

    1.wget

    2.解压

二。编译:

    1.参数:

   

mysql 5.1编译参数和编译方法_第1张图片

  ./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


2.make && make intall
3.复制mysql配置文件,此处为测试,使用占用资源最少的small.cnf
  cp my-small.cnf /etc/my.cnf

4.建立安装文件目录。并把文件夹的属主递归改为mysql

  mkdir -p /usr/local/mysql

  chown -R mysql.mysql /usr/local/mysql/

  5.安装数据库:

  /usr/local/mysql/bin/mysql_install_db --user=mysql

 6.修复警告

WARNING: The host 'ser200' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
141018 15:29:28 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
OK
Filling help tables...
141018 15:29:28 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
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:

/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h ser200 password 'new-password'


VI修改hosts文件,增加mysql

[root@ser200 data]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               mysql ser150    localhost
::1             localhost6.localdomain6 localhost6

7.增加环境变量mysql路径

[root@ser200 data]# echo "export PATH=$PATH:/usr/local/mysql/bin">> /etc/profile

[root@ser200 data]# . /etc/profile
[root@ser200 data]# echo $PATH


8.增加mysql 自启动和init.d的服务器启动2种方式

[root@ser200 data]# cp /home/oldboy/tools/mysql-5.1.73/support-files/mysql.server /etc/init.d/mysqld
[root@ser200 data]# chmod 700 /etc/init.d/mysqld
[root@ser200 data]# ll /etc/init.d/mysqld
-rwx------ 1 root root 12533 Oct 18 15:54 /etc/init.d/mysqld

===========================================================

[root@ser200 data]# chkconfig --add mysql

[root@ser200 data]# chkconfig --list|grep mysqld
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off


9.删除mysql库user表多余的用户

mysql> select user,host from user;    
+------+-----------+
| user | host      |
+------+-----------+
| root | 127.0.0.1 |
|      | localhost |
| root | localhost |
|      | ser200    |
| root | ser200    |
+------+-----------+
5 rows in set (0.00 sec)

mysql> drop user ""@localhost

mysql> drop user ""@ser200

mysql>drop user root@ser200

mysql> drop user root@ser200