> CentOS > CentOS教程 >

Centos7编译安装MySQL5.5

关闭防火墙                                                
Systemctl stop firewall
Setenforce 0
检查是否安装过MySQL                                       
rpm -qa |grep mysql
[root@localhost~]# rpm -qa|grep mariadb   centos7默认数据库
mariadb-libs-5.5.44-1.el7_1.x86_64
[root@localhost~]# rpm -e --nodeps mariadb-libs-5.5.44-1.el7_1 强制卸载
安装编译代码所需要的包                                    
 
[root@localhost ~]# yum -y install make gcc-c++ cmake bison-devel ncurses-devel libaio libaio-devel perl-Data-Dumper net-tools
解压并安装                                                
[root@localhost ~]# tar zxf mysql-5.5.17.tar.gz
[root@localhost ~]# cd mysql-5.5.17/
[root@localhost mysql-5.5.17]# cmake \
> -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
> -DMYSQL_DATADIR=/usr/local/mysql/data \
> -DSYSCONFDIR=/etc \
> -DWITH_MYISAM_STORAGE_ENGINE=1 \
> -DWITH_INNOBASE_STORAGE_ENGINE=1 \
> -DWITH_MEMORY_STORAGE_ENGINE=1 \
> -DWITH_READLINE=1 \
> -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
> -DMYSQL_TCP_PORT=3306 \
> -DENABLED_LOCAL_INFILE=1 \
> -DWITH_PARTITION_STORAGE_ENGINE=1 \
> -DEXTRA_CHARSETS=all \
> -DDEFAULT_CHARSET=utf8 \
> -DDEFAULT_COLLATION=utf8_general_ci
[root@localhost mysql-5.5.17]# make && make install
创建MySQL用户组和用户                                          
[root@localhost mysql-5.5.17]# groupadd mysql
[root@localhost mysql-5.5.17]# useradd -g mysql mysql
修改mysql目录权限
[root@localhost mysql-5.5.17]# chown -R mysql:mysql /usr/local/mysql
启动mysql
拷贝文件
[root@localhost mysql-5.5.17]# cp support-files/mysql.server /etc/init.d/mysql
[root@localhost mysql-5.5.17]# chkconfig mysql on              #开机启动
[root@localhost mysql-5.5.17]# service mysql  start        #启动mysql
Starting MySQL... SUCCESS!
Netstat -lnp|grep 3306                   #检查端口


(责任编辑:IT)