首页 > 代码库 > Linux下安装MySQL

Linux下安装MySQL

来源:http://www.cnblogs.com/chenjunbiao/archive/2011/01/24/1940256.html

安装环境:Linux服务器CentOS 5.5

安装版本:mysql-5.5.8.tar.gz

1、安装cmake编译器。

1)、下载cmake

#cd /usr/local/src#wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz

2)、解压cmake

#tar -zvxf cmake-2.8.4.tar.gz

3)、配置编译

#cd cmake-2.8.4#yum -y install gcc#yum -y install gcc-c++#yum -y install ncurses-devel#./configure#make#make install 

2、安装MySQL

1)、下载MySQL。

#cd /usr/local/src#wget http://sdk.ruiya.com/linux/mysql-5.5.9.tar.gz

2)、添加必要的组和拥有者

#groupadd mysql#useradd -r -g mysql mysql 

3)、解压MySQL

#tar -zvxf mysql-5.5.9.tar.gz

4)、配置编译

如果是重装MySql,请先删除my.cnf如: rm -rf /etc/my.cnf

#mkdir /usr/local/mysql#mkdir /usr/local/mysql/data#cd /usr/local/src/mysql-5.5.9#cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DINSTALL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1#make#make install

参数说明:

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql        //安装目录-DINSTALL_DATADIR=/usr/local/mysql/data        //数据库存放目录-DDEFAULT_CHARSET=utf8                       //使用utf8字符-DDEFAULT_COLLATION=utf8_general_ci            //校验字符-DEXTRA_CHARSETS=all                          //安装所有扩展字符集-DENABLED_LOCAL_INFILE=1                      //允许从本地导入数据

注意事项:

重新编译时,需要清除旧的对象文件和缓存信息。 

# make clean# rm -f  CMakeCache.txt# rm -rf /etc/my.cnf 

4)、设置目录权限

# cd /usr/local/mysql# chown -R root:mysql . //把当前目录中所有文件的所有者所有者设为root,所属组为mysql# chown -R mysql:mysql data

5)、配置文件

# cp support-files/my-medium.cnf /etc/my.cnf //这个配置仅适合小内存系统(32M - 64M)

打开如下注释:

innodb_data_home_dir = /usr/local/mysql/datainnodb_data_file_path = ibdata1:10M:autoextendinnodb_log_group_home_dir = /usr/local/mysql/datainnodb_buffer_pool_size = 16Minnodb_additional_mem_pool_size = 2Minnodb_log_file_size = 5Minnodb_log_buffer_size = 8Minnodb_flush_log_at_trx_commit = 1innodb_lock_wait_timeout = 50

 

Linux下安装MySQL