我们去下载mysql源码安装包和cmake包
安装mysql的时候需要使用到cmake,其次我们还要使用yum安装一些环境
yum -y install ncurses-devel gcc-c++ gcc openssl* perl*
下载mysql源码包
http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.51.tar.gzhttp://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.51.tar.gz
进入网址自动下载
下载cmake源码包
下载一个tar.gz的Linux归档
https://objects.githubusercontent.com/github-production-release-asset-2e65be/537699/264b8b80-f6ec-11e8-83a6-cf137e66b9f1?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230923T121658Z&X-Amz-Expires=300&X-Amz-Signature=72ca309f41eb04672c00ba61afae393e1f7857af7b65e4347b82e78ae5360ee6&X-Amz-SignedHeaders=host&actor_id=121765542&key_id=0&repo_id=537699&response-content-disposition=attachment%3B%20filename%3Dcmake-2.8.10.2.tar.gz&response-content-type=application%2Foctet-streamhttps://objects.githubusercontent.com/github-production-release-asset-2e65be/537699/264b8b80-f6ec-11e8-83a6-cf137e66b9f1?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230923T121658Z&X-Amz-Expires=300&X-Amz-Signature=72ca309f41eb04672c00ba61afae393e1f7857af7b65e4347b82e78ae5360ee6&X-Amz-SignedHeaders=host&actor_id=121765542&key_id=0&repo_id=537699&response-content-disposition=attachment%3B%20filename%3Dcmake-2.8.10.2.tar.gz&response-content-type=application%2Foctet-stream↑这个也可直接进入上面那个链接自动下载
开始安装mysql
把刚刚那两个包全部放入Linux
tar zxf cmake-*.tar.gz
cd cmake-*
./configure
gmake && gmake install
cmake安装好了
groupadd mysql
useradd -M -s /sbin/nologin -g mysql mysql
cd
回到默认目录,和mysql解压包同级目录
tar zxvf mysql-*.tar.gz -C /usr/src/
cd /usr/src/mysql-*
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc
make && make install
chown -R mysql:mysql /usr/local/mysql
rm -rf /etc/my.cnf
cp support-files/my-default.cnf /etc/my.cnf
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/
初始化
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
写入环境变量
source /etc/profile
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
写入系统服务
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
现在就安装好了
现在就正式安装好了
chkconfig mysqld on
开启开机自启
chkconfig mysqld off
关闭开机自启
systemctl start mysqld