日期:2014-05-16  浏览次数:20811 次

oracle linux 6下自定义安装mysql

环境:Oracle Linux 6(64 bit)

下载mysql: http://dev.mysql.com/downloads/mysql/5.1.html 版本:5.5.36 平台:Source Code

Generic Linux (Architecture Independent), Compressed TAR Archive(mysql-5.5.36.tar.gz)  下载20.7M的这个包

接下来用cmake来安装mysql,安装之前先确保已安装cmake:rpm -qa|grep cmake,并卸载旧版本的mysql


解压
tar -xzvf mysql-5.5.36.tar.gz 
创建安装目录
cd /u02
mkdir mysql
mkdir mysql/data
chmod -R 755 mysql-5.5.36
chmod -R 755 mysql


编译安装mysql 5.5.36
cd /u02/mysql-5.5.36
cmake -DCMAKE_INSTALL_PREFIX=/u02/mysql && make && make install
scripts/mysql_install_db \
--basedir=/u02/mysql \
--datadir=/u02/mysql/data \ 
--user=grid


cmake时的其他参数:

-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ 
-DDEFAULT_CHARSET=utf8 \ 
-DDEFAULT_COLLATION=utf8_general_ci \ 
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \ 
-DWITH_MYISAM_STORAGE_ENGINE=1 \ 
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ 
-DWITH_READLINE=1 \ 
-DENABLED_LOCAL_INFILE=1 \ 
-DMYSQL_DATADIR=/var/mysql/data



修改配置文件
cp support-files/my-medium.cnf /u02/mysql/my.cnf
chown -R grid:grid /u02/mysql




vi /u02/mysql/my.cnf  //加上以下内容  
[mysqld]   
basedir = /u02/mysql   
datadir = /u02/mysql/data   
log-error = /u02/mysql/mysql_error.log   
pid-file = /u02/mysql/mysql.pid   
user = grid   
tmpdir = /tmp


启动mysql
bin/mysqld_safe --user=grid &




将mysql加入开机启动
cd /u02/mysql/support-files
cp ./mysql.server /etc/init.d/mysqld
/etc/init.d/mysqld start
chmod +x /etc/init.d/mysqld




vi /etc/init.d/mysqld (编辑此文件,查找并修改以下变量内容:)
 basedir=/usr/local/mysql
 datadir=/var/mysql/data




查看服务是否已经添加到linux上
chkconfig --list mysqld
chkconfig --add mysqld
chkconfig --level 345 mysqld on




设置环境变量
vi /etc/profile
export PATH=$PATH:/u02/mysql/bin
source /etc/profile




启动mysql服务