1. 源代码包下载 源代码包通常也採用tar.gz压缩。名称中仅仅包括版本号信息,大小也比RPM包、二进制包小非常多,解压后的文件里含有INSTALL-SOURCE文件。可从MySQL官网(http://www.mysql.com/downloads/)下载,如:mysql-5.5.17.tar.gz2. CMake在採用源代码包安装MySQL实例之前,先来介绍一下cmake这个编译工具。
在MySQL 5.5之前。是採用configure工具运行源代码编译的,到了MySQL 5.5,改用cmake进行编译。这是一个比make更高级的编译配置工具。可依据不同平台、不同编译器。生产对应的Makefile或者vcproj项目,所以须要首先从官网(http://www.cmake.org)下载cmake工具并安装之。
安装cmake之前安装gcc包rpm -ivh kernel-headers-2.6.18-308.el5.x86_64.rpmrpm -ivh glibc-headers-2.5-81.x86_64.rpmrpm -ivh glibc-devel-2.5-81.x86_64.rpmrpm -ivh gcc-4.1.2-52.el5.x86_64.rpmrpm -ivh libstdc++-devel-4.1.2-52.el5.x86_64.rpmrpm -ivh gcc-c++-4.1.2-52.el5.x86_64.rpm安装cmake/mysql/cmake-2.8.3./configuregmake && make install 3. 安装mysql 5.5.17 1. 创建mysql系统组及用户 groupadd mysql useradd –g mysql mysql 2. 设置用户操作系统资源限制 vi /etc/security/limits.conf mysql soft nproc 2047 mysql hard nproc 16384 mysql soft nofile 1024 mysql hard nofile 65536 安装须要包 # rpm -ivh ncurses-devel-5.5-24.20060715.x86_64.rpm # rpm -ivh bison-2.3-2.1.x86_64.rpm 3. 安装MYSQL Server #mkdir /opt/mysql #chown -R mysql:mysql /opt/mysql #gunzip mysql-5.5.17.tar.gz #tar xvf mysql-5.5.17.tar #cd mysql-5.5.17 # cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql \ > -DMYSQL_USER=mysql \ > -DMYSQL_TCP_PORT=3306 \ > -DMYSQL_DATADIR=/opt/mysql/data \ > -DWITH_MYISAM_STORAGE_ENGINE=1 \ > -DWITH_INNOBASE_STORAGE_ENGINE=1 \ > -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ > -DWITH_MEMORY_STORAGE_ENGINE=1 \ > -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ > -DWITH_PARTITION_STORAGE_ENGINE=1 \ > -DENABLED_LOCAL_INFILE=1 \ > -DWITH_READLINE=1 \ > -DWITH_SSL=yes \ > -DDEFAULT_CHARSET=utf8 \ > -DDEFAULT_COLLATION=utf8_general_ci \ > -DEXTRA_CHARSETS=all #make #make install 初始化DB # sh scripts/mysql_install_db --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data 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 mysql 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/scripts/mysqlbug script! 4. 启动Mysql Sever配置service服务# cp /opt/mysql/files/mysql.server /etc/init.d/mysql --配置basedir、datadir配置mysql參数文件my.cnf #vi /etc/my.cnf[client]#password = your_passwordport = 3306socket = /opt/mysql/data/mysql.sock [mysqld]port = 3306server-id = 24datadir = /opt/mysql/datasocket = /opt/mysql/data/mysql.sockpid-file = /opt/mysql/data/mysql.pidcharacter-set-server = utf8default_storage_engine = InnoDBlog-bin = /opt/mysql/data/mysql-binbinlog_format = rowsync-binlog = 1slow-query-log = onslow-query-log-file = /opt/mysql/data/mysql-slow.loglog_error = /opt/mysql/data/mysql.errmax_connections = 2000back_log = 50skip-external-lockingskip-name-resolve key_buffer_size = 256Mmax_allowed_packet = 1Mtable_open_cache = 2000sort_buffer_size = 1Mread_buffer_size = 1Mread_rnd_buffer_size = 4Mmyisam_sort_buffer_size = 64Mthread_cache_size = 8query_cache_size = 16Mthread_concurrency = 8 innodb_data_home_dir = /opt/mysql/datainnodb_data_file_path = ibdata1:10M:autoextendinnodb_log_group_home_dir = /opt/mysql/datainnodb_buffer_pool_size = 256Minnodb_additional_mem_pool_size = 20Minnodb_log_file_size = 64Minnodb_log_buffer_size = 8Minnodb_flush_log_at_trx_commit = 1innodb_lock_wait_timeout = 50 [mysqldump]quickmax_allowed_packet = 16M [mysql]no-auto-rehash#safe-updates [myisamchk]key_buffer_size = 128Msort_buffer_size = 128Mread_buffer = 2Mwrite_buffer = 2M [mysqlhotcopy]interactive-timeout "/etc/my.cnf" [New] 62L, 1531C written[root@mysql support-files]# more /etc/my.cnf [client]#password = your_passwordport = 3306socket = /opt/data/mysql.sock [mysqld]port = 3306 server-id = 24datadir = /opt/mysql/datasocket = /opt/mysql/data/mysql.sockpid-file = /opt/mysql/data/mysql.pidcharacter-set-server = utf8default_storage_engine = InnoDBlog-bin = /opt/mysql/data/mysql-binbinlog_format = rowsync-binlog = 1 slow-query-log = onslow-query-log-file = /opt/mysql/data/mysql-slow.loglog_error = /opt/mysql/data/mysql.errmax_connections = 2000back_log = 50skip-external-lockingskip-name-resolve key_buffer_size = 256Mmax_allowed_packet = 1Mtable_open_cache = 2000sort_buffer_size = 1Mread_buffer_size = 1Mread_rnd_buffer_size = 4Mmyisam_sort_buffer_size = 64Mthread_cache_size = 8query_cache_size = 16Mthread_concurrency = 8 innodb_data_home_dir = /opt/mysql/datainnodb_data_file_path = ibdata1:10M:autoextendinnodb_log_group_home_dir = /opt/mysql/datainnodb_buffer_pool_size = 256Minnodb_additional_mem_pool_size = 20Minnodb_log_file_size = 64Minnodb_log_buffer_size = 8Minnodb_flush_log_at_trx_commit = 1innodb_lock_wait_timeout = 50 [mysqldump]quickmax_allowed_packet = 16M [mysql]no-auto-rehash#safe-updates [myisamchk]key_buffer_size = 128Msort_buffer_size = 128Mread_buffer = 2Mwrite_buffer = 2M [mysqlhotcopy]interactive-timeout # service mysql startStarting MySQL....[ OK ]