1:依赖软件安装


yum install gcc gcc-c++ ncurses-devel perl  


2:安装cmake

wget --no-check-certificate http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz 

tar zxvf cmake-2.8.4.tar.gz 

cd cmake-2.8.4

 ./configure && make && make install


3:新建mysql用户和组

groupadd mysql

useradd -g mysql mysql


4:新建mysql安装目录和数据目录

mkdir -p /usr/local/mysql

mkdir -p /data/mysqldb


5:

5:下载mysql

6:解压安装

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DMYSQL_DATADIR=/data/mysqldb -DSYSCONFDIR=/etc -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DWITH_XTRADB_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -

DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DWITH_EXTRA_CHARSETS=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BIG_TABLES=1 -DWITH_DEBUG=0



mkdir && mkdir install


7:复制mysql服务启动配置文件

cp support-files/my-small.cnf /etc/my.cnf


8:复制mysql服务启动脚本及加入PATH路径

cp support-files/mysql.server /etc/init.d/mysqld


vim /etc/profile   

  

 PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH  

  

 export PATH  


source /etc/profile    


9:初始化mysql数据库


/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb/ --basedir=/usr/local/mysql


ln -fs /usr/local/mysql/bin/mysql /usr/local/bin/

10:修改root密码

mysqladmin -u root password '123'



开启mysql日志

在my.cnf的[mysqld]下配置常用的几个日志

log-error=/usr/local/mysql/log/error.log

log=/usr/local/mysql/log/mysql.log

log-slow-queries= /usr/local/mysql/log/slowquery.log