从下面地址获取centos版本对应的epel的版本,对今后yum安装软件有帮助
wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
安装epel包
rpm -ivh epel-release-6-8.noarch.rpm
安装必须的软件包
yum install cmake gcc gcc-c++ ncurses-devel perl
下载Mysql安装包,下载地址mysql-5.5安装包,并解压安装包
tar -zxvf mysql-5.5.32.tar.gz cd mysql-5.5.32
编译安装
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysqldb -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DWITH_EXAMPLE_STORAGE_ENGINE=1 \-DWITH_PARTITION_STORAGE_ENGINE=1 \-DWITH_FAST_MUTEXES=1 \-DWITH_ZLIB=bundled \-DENABLED_LOCAL_INFILE=1 \-DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock-DENABLED_LOCAL_INFILE=ON -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_DEBUG=0 make && make install
设置Mysql用户和组
groupadd mysql useradd -g mysql mysql
新建Mysql安装目录和数据文件目录
mkdir -p /usr/local/mysql mkdir -p /data/mysqldb
修改目录所有者和组
chown -R mysql:mysql /usr/local/mysql chown -R mysql:mysql /data/mysqldb
cd /usr/local/mysql scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb --basedir=/usr/local/mysql
复制Mysql服务启动配置文件,my.cnf有数据就覆盖掉
cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf
复制Mysql服务启动脚本
cp support-files/mysql.server /etc/init.d/mysqld
修改/etc/profile文件,末尾添加PATH
PATH=/usr/local/mysql/bin:$PATH export PATH
保存修改,让配置立即生效
source /etc/profile
五、启动数据库幷登录
service mysqld start
登录数据库
mysql -uroot
本文出自 “数据库学习历程” 博客,请务必保留此出处http://yuemu.blog.51cto.com/10688235/1868159
原文地址:http://yuemu.blog.51cto.com/10688235/1868159