目前各大門戶網站均在一定程度上偏向mysql的使用,加上阿裡系倡導的去I/O/E運動,先前一直輕視mysql的觀點必須要改正下,況且做為一個資料庫從業者,必須要熟悉2種以上的rdbms資料庫,因而今後的學習重點依然是oracle,mysql則作為一個延伸方向!本文主要記錄mysql5.5版本在linux平台的編譯安裝過程,mysql在5.1和5.5版本上存在比較大的差别,5.1之後提供了分區表的功能,5.5版本上預設的存儲引擎改為innodb,5.1之前則是myisam
1:安裝必要的rpm包,建立mysql使用者組,本文采用的作業系統平台為rhel5.4
[root@dg53 ~]# grep -v '^#' /etc/yum.repos.d/base.repo |grep -v '^$'
[base]
name=base
baseurl=file:///mnt/Server
gpgcheck=0
enable=1
[root@dg53 ~]# mount /dev/cdrom /mnt
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@dg53 ~]# yum -y install gcc gcc-c++ gcc-g77 autoconf automake \
zlib* fiex** libxml* ncurses-devel libmcrypt* libtool-ltdl-devel*
[root@dg53 ~]# id mysql
uid=27(mysql) gid=27(mysql) groups=27(mysql)
2:下載下傳cmake和mysql源碼包,進行編譯安裝,mysql5.5版本需要使用cmake編譯
[root@dg53 ~]# cd /usr/local/src/tarbag/
[root@dg53 tarbag]# wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
[root@dg53 tarbag]# wget http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.25.tar.gz
[root@dg53 tarbag]# tar -zxvpf cmake-2.8.4.tar.gz -C ../software/
[root@dg53 tarbag]# tar -zxvpf mysql-5.5.25.tar.gz -C ../software/
[root@dg53 tarbag]# cd ../software/cmake-2.8.4/
[root@dg53 cmake-2.8.4]# ./configure --prefix=/usr/local/cmake2.8.4 && make && make install
[root@dg53 ~]# grep PATH .bash_profile
PATH=$PATH:$HOME/bin:/usr/local/cmake2.8.4/bin:$PATH
export PATH
[root@dg53 ~]# . .bash_profile
[root@dg53 ~]# cd /usr/local/src/software/mysql-5.5.25/
[root@dg53 mysql-5.5.25]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.5.25 \
-DMYSQL_DATADIR=/mydata \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DMYSQL_TCP_PORT=3306 -DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_DEBUG=0
[root@dg53 mysql-5.5.25]# make && make install
3:初始化mysql服務
[root@dg53 mysql-5.5.25]# cp support-files/my-large.cnf /etc/my.cnf
[root@dg53 mysql-5.5.25]# cp support-files/mysql.server /etc/init.d/mysqld
[root@dg53 mysql-5.5.25]# chmod +x /etc/init.d/mysqld
[root@dg53 mysql-5.5.25]# chkconfig --add mysqld
[root@dg53 mysql-5.5.25]# sh ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql5.5.25/ --datadir=/mydata/
[root@dg53 mysql-5.5.25]# service mysqld start
Starting MySQL...[ OK ]
[root@dg53 ~]# echo '/usr/local/mysql5.5.25/include/' >> /etc/ld.so.conf
[root@dg53 ~]# echo '/usr/local/mysql5.5.25/lib/' >> /etc/ld.so.conf
[root@dg53 ~]# ldconfig
4:測試安裝結果
[root@dg53 mysql-5.5.25]# /usr/local/mysql5.5.25/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.25-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select user,password,host from mysql.user;
+------+----------+---------------+
| user | password | host |
| root | | localhost |
| root | | dg53.yang.com |
| root | | 127.0.0.1 |
| root | | ::1 |
| | | localhost |
| | | dg53.yang.com |
6 rows in set (0.00 sec)
mysql> show plugins;
+-----------------------+--------+--------------------+---------+---------+
| Name | Status | Type | Library | License |
| binlog | ACTIVE | STORAGE ENGINE | NULL | GPL |
| mysql_native_password | ACTIVE | AUTHENTICATION | NULL | GPL |
| mysql_old_password | ACTIVE | AUTHENTICATION | NULL | GPL |
| CSV | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MEMORY | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MyISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MRG_MYISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |
| PERFORMANCE_SCHEMA | ACTIVE | STORAGE ENGINE | NULL | GPL |
| InnoDB | ACTIVE | STORAGE ENGINE | NULL | GPL |
| INNODB_TRX | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_LOCKS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_LOCK_WAITS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMP | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMP_RESET | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMPMEM | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMPMEM_RESET | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| partition | ACTIVE | STORAGE ENGINE | NULL | GPL |
17 rows in set (0.00 sec)
mysql> show variables like '%default%';
+------------------------+--------+
| Variable_name | Value |
| default_storage_engine | InnoDB |
| default_week_format | 0 |
2 rows in set (0.00 sec)
mysql> show variables like '%character%';
+--------------------------+----------------------------------------+
| Variable_name | Value |
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql5.5.25/share/charsets/ |
8 rows in set (0.00 sec)
本文轉自斬月部落格51CTO部落格,原文連結http://blog.51cto.com/ylw6006/883598如需轉載請自行聯系原作者
ylw6006