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