1、首先需要编译器gcc 编译器和cmake
yum -y install gcc+ gcc-c++
cd /usr/local/src wget http://www.cmake.org/files/v3.2/cmake-3.2.1.tar.gz
安装cmake
1 [root@xt test]# tar -zxvf cmake-3.2.1.tar.gz 2 [root@xt test]# cd cmake-3.2.1.tar.gz 3 [root@xt apr-1.4.5]# ./configure --prefix=/usr/local/cmake 4 [root@xt apr-1.4.5]# make && make install
2、下载MySQL5.6.24
wget http://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-5.6/mysql-5.6.24.tar.gz
#解压mysql tar zxvf mysql-5.6.24.tar.gz #进入mysql目录 cd mysql-5.6.24 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql_data -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_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
#编译安装mysql5.6 make && make install #新建一个mysql用户 useradd -s /sbin/nologin mysql #新建一个数据目录 mkdir -p /data/mysql_data #赋予权限 chown -R mysql:mysql /usr/local/mysql chown -R mysql:mysql /data/mysql_data #进入到mysql安装目录 cd /usr/local/mysql/scripts/ #执行以下命令,初始化数据库 ./mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql_data --user=mysql #在CentOS6.5系统的最小安装完成后,在/etc目录下会存在一个my.cnf,需要将此文件更名为其他的名字,如:/etc/my.cnf.old,否则,该文件会干扰源码安装的MySQL的正确配置,造成无法启动。 mv /etc/my.cnf /etc/my.cnf.old #复制我们需要的my.cnf到etc下 cp /usr/local/mysql/my.cnf /etc/ #复制启动脚本到/etc/init.d cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld #iptables添加3306端口 vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT #重启iptables service iptables restart #启动mysql service mysqld start #开机启动mysql chkconfig mysqld on #设置环境变量 vi /etc/profile #在末尾添加以下内容 PATH=/usr/local/mysql/bin:$PATH export PATH #让刚才的修改生效 source /etc/profile #初始化mysql的一些设置 mysql_secure_installation #回车 Enter current password for root (enter for none): #y,设置mysql的root密码 Set root password? [Y/n] y #以下都yes Remove anonymous users? [Y/n] y Disallow root login remotely? [Y/n] y Remove test database and access to it? [Y/n] y Reload privilege tables now? [Y/n] y Thanks for using MySQL!
进入MySQL
[root@****]# /usr/local/mysql/bin/mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.40-log MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>