--1.为mysql新建组和用户
# useradd -M -s /sbin/nologin mysql |
--2.安装需要的库,编译器
# yum install ncurses-devel openssl-devel cmake -y |
--3.解压
# tar zxvf mysql-5.6.35.tar.gz# cd mysql-5.6.35 |
--4.编译安装
# 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_TCP_PORT=3306 /-DENABLED_LOCAL_INFILE=1 /-DWITH_PARTITION_STORAGE_ENGINE=1 /-DEXTRA_CHARSETS=all /-DDEFAULT_CHARSET=utf8 /-DDEFAULT_COLLATION=utf8_general_ci /-DMYSQL_USER=mysql /-DWITH_DEBUG=0 /-DWITH_SSL=system# make# make install |
--5.拷贝模版,作为配置文件
# cp support-files/my-default.cnf /etc/my.cnf |
--6.设置mysql权限
# chown -R mysql.mysql /usr/local/mysql/ |
--7.初始化mysql数据库
# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql# chown -R root /usr/local/mysql/# chown -R mysql /usr/local/mysql/data/ |
--8.设置mysql开机自启动
# cp support-files/mysql.server /etc/init.d/mysqld# chmod +x /etc/init.d/mysqld# chkconfig mysqld on |
--9.测试并运行mysql
#service mysqld start |
--10.修改mysql管理员密码
#/usr/local/mysql/bin/mysqladmin -u root password '要设置的密码' |
--11.使用用户登录mysql
# /usr/local/mysql/bin/mysql -u root -p |
--12.加入环境变量
# echo 'PATH=/usr/local/mysql/bin/:$PATH' >>/etc/profile# source /etc/profile |
CentOS 6.5最小化编译安装mysql 5.5.35配置多实例
1、关闭防火墙
1234567 [root@mysql ~]# service iptables stopiptables: 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 --listiptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off |
2、关闭selinux
12 [root@mysql ~]# setenforce 0[root@mysql ~]# vim /etc/sysconfig/selinux |
修改下面这一行;
SELINUX=disabled12 [root@mysql ~]# getenforce Permissive |
3、安装mysql依赖包及编译工具;
1234 [root@mysql ~]# yum install libaio-devel -y[root@mysql ~]# yum install -y ncurses-devel[root@mysql ~]# yum install -y gcc gcc-c++ [root@mysql ~]# yum install -y cmake |