CentOS 6.5最小化编译安装mysql 5.5.35
1、关闭防火墙;
[root@mysql ~]# service iptables stop iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Flushing firewall rules: [ OK ] iptables: Unloading modules: [ OK ] [root@mysql ~]# chkconfig iptables off [root@mysql ~]# chkconfig iptables --list iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
2、关闭selinux;
[root@mysql ~]# setenforce 0 [root@mysql ~]# vim /etc/sysconfig/selinux
修改下面这一行;
SELINUX=disabled [root@mysql ~]# getenforce Permissive
3、安装mysql依赖包及编译工具;
[root@mysql ~]# yum install -y ncurses-devel [root@mysql ~]# yum install -y gcc gcc-c++ [root@mysql ~]# yum install -y cmake
4、安装前准备;
4.1、安装路径;
[root@mysql ~]# mkdir /usr/local/mysql
4.2、数据库路径;
[root@mysql ~]# mkdir /data/mysql -p
4.3、创建用户和用户组;
[root@mysql ~]# groupadd mysql [root@mysql ~]# useradd -r -g mysql -s /bin/false mysql
4.4、赋予数据存放目录权限;
[root@mysql ~]# chown mysql:mysql -R /data/mysql
5、编译安装mysql 5.5.35;
5.1、编译安装mysql 5.5.35
[root@mysql ~]# yum install -y lrzsz root@mysql ~]# mkdir /package [root@mysql ~]# cd /package/ [root@mysql package]# tar xf mysql-5.5.32.tar.gz [root@mysql package]# cd mysql-5.5.32 [root@mysql mysql-5.5.32]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/data/mysql/ -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 [root@mysql mysql-5.5.32]# make && make install
5.2、复制配置文件;
[root@mysql mysql-5.5.32]# cp support-files/my-small.cnf /etc/my.cnf cp: overwrite `/etc/my.cnf‘? yes
5.3、进入安装目录;
[root@mysql mysql-5.5.32]# cd /usr/local/mysql/ [root@mysql mysql]# ll scripts/ total 16 -rwxr-xr-x. 1 root root 14816 Aug 2 00:13 mysql_install_db
5.4、初始化数据库;
[root@mysql mysql]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/
5.5、创建管理数据库的脚本并添加到服务列表;
[root@mysql mysql]# cp support-files/mysql.server /etc/init.d/mysqld [root@mysql mysql]# chmod +x !$ chmod +x /etc/init.d/mysqld [root@mysql mysql]# chkconfig --add mysqld [root@mysql mysql]# chkconfig mysqld --list mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
6、安装完成;
6.1、启动数据库;
[root@mysql mysql]# /etc/init.d/mysqld start Starting MySQL.. SUCCESS!
6.2、登陆数据库;
[root@mysql mysql]# /usr/local/mysql/bin/mysql
本文出自 “duan_fei's blog” 博客,请务必保留此出处http://xiaofeifei.blog.51cto.com/10174812/1833039
原文地址:http://xiaofeifei.blog.51cto.com/10174812/1833039