1.安装准备
cat /etc/redhat-release uname -r yum install ncurses-devel cmake automake autoconf make gcc gcc-c++ bison -y mkdir /application/data -p groupadd mysql useradd -g mysql -s /sbin/nologin -M mysql |
2.源码安装
cd tools
tar xf mysql-5.5.46.tar.gz cmake .-DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.46 \ -DMYSQL_DATADIR=/application/data \ -DMYSQL_UNIX_ADDR=/application/mysql-5.5.46/tmp/mysql.sock\ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \ -DENABLED_LOCAL_INFILE=ON \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \ -DWITHOUT_PARTITION_STORAGE_ENGINE=1 \ -DWITH_FAST_MUTEXES=1 \ -DWITH_ZLIB=bundled \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_READLINE=1 \ -DWITH_EMBEDDED_SERVER=1 \ -DWITH_DEBUG=0 make && makeinstall |
3.Mysql初始化及配置
ln -s /application/mysql-5.5.46/ /application/mysql
cp support-files/my-small.cnf /etc/my.cnf cd /application chown -R mysql.mysql data chmod -R 1777 /tmp/ cd /application/mysql/scripts/ ./mysql_install_db --basedir=/application/mysql --datadir=/application/data --user=mysql |
4.加入开机启动
cp /root/tools/mysql-5.5.46/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on chkconfig mysqld --list /etc/init.d/mysqld start netstat -tunlp|grep mysqld lsof -i:3306 |
5.设置Mysql环境变量
echo "PATH=/application/mysql/bin/:$PATH" >> /etc/profile
source /etc/profile which mysql |