前言
近期Mysql已经发布了最新的8.0.26 RPM包,此文是在CentOS7.3环境下部署Mysql8.0.26 刚开始以为很简单,可是实际的过程中发现8.0.26有很多坑,需要升级的地方很多,后期还是建议在Linux高版本安装部署,特总结了以下详细的安装过程分享给大家。 整个过程有4个坑,希望对DBA们有帮助
百度网盘下载所需要的包
链接:https://pan.baidu.com/s/12g05_QUF-wFgWSQ1-vrIXQ
提取码:fpt5
如下图所示:
一、 环境确认
1.1 操作系统
[root@jeames ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core)
1.2 防火墻
[root@jeames ~]# systemctl status firewalld --关闭防火墙 systemctl stop firewalld
1.3 selinux关闭
[root@jeames ~]# sestatus SELinux status: disabled [root@jeames ~]# getenforce Disabled
1.4 卸载mariadb
--卸载centos7中自带的mariadb [root@jeames ~]# rpm -qa|grep mariadb rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
二、 安装部署
2.1 yum安装
yum -y install lrzsz wget perl-Digest-MD5 yum -y install numactl yum -y install ncurses ncurses-devel openssl-devel bison gcc gcc-c++ make
2.2 添加用户及组
[root@jeames ~]# groupadd mysql 删除组:groupdel users --用户加到组并指定根目录 [root@jeames ~]# useradd -g mysql -d /home/mysql mysql useradd: warning: the home directory already exists. Not copying any file from skel directory into it. 删除用户:userdel mysql [root@jeames ~]# passwd mysql New password: BAD PASSWORD: The password is shorter than 8 characters Retype new password: passwd: all authentication tokens updated successfully.
2.3 安装Mysql
**2.3.1 解压安装包** [root@jeames ~]# md5sum mysql-8.0.27-1.el8.x86_64.rpm-bundle.tar edf4d0f95867f62cdcc97b7349bedc59 mysql-8.0.27-1.el8.x86_64.rpm-bundle.tar [root@jeames ~]# tar -xvf mysql-8.0.27-1.el8.x86_64.rpm-bundle.tar -C /home/mysql/
必须安装的四个 mysql-community-common-8.0.27-1.el8.x86_64.rpm mysql-community-libs-8.0.27-1.el8.x86_64.rpm mysql-community-client-8.0.27-1.el8.x86_64.rpm 是客户端的安装包 mysql-community-server-8.0.27-1.el8.x86_64.rpm 是服务端的安装包
2.3.2.授权
[root@jeames ~]# chown -R mysql:mysql /home/mysql/
2.3.3 安装
注:root用户下操作 [root@jeames ~]# cd /home/mysql/ 装顺序:包之间相互依赖,所以必须注意安装顺序 ✓ 先装 common ✓ 再装 libs 确保 mariadb 已卸载,centos7 默认支持 mariadb,不支持 mysql,不卸载会出现冲突 ✓ 再装 client ✓ 最后装 server
[root@jeames mysql]# rpm -ivh mysql-community-common-8.0.27-1.el8.x86_64.rpm
[root@jeames mysql]# rpm -ivh --force --nodeps mysql-community-libs-8.0.27-1.el8.x86_64.rpm
[root@jeames mysql]# rpm -ivh mysql-community-client-8.0.27-1.el8.x86_64.rpm --force --nodeps
[root@jeames mysql]# rpm -ivh mysql-community-server-8.0.27-1.el8.x86_64.rpm --force --nodeps
2.3.4 初始化
此处第一个坑
[root@jeames mysql]# mysqld --initialize mysqld: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory 注意:此处报错请看以下博客处理: https://blog.csdn.net/weixin_41645135/article/details/121479431
此处第2个坑
[root@jeames mysql]# mysqld --initialize
处理方法: wget http://ftp.de.debian.org/debian/pool/main/g/gcc-8/libstdc++6_8.3.0-6_amd64.deb ar -x libstdc++6_8.3.0-6_amd64.deb tar -xvf data.tar.xz find / -name "libstdc++*" [root@jeames ~]# cp /root/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25 /usr/lib64/ [root@jeames ~]# ll /usr/lib64/libstd* [root@jeames ~]# rm -rf /usr/lib64/libstdc++.so.6 [root@jeames ~]# ln -s /usr/lib64/libstdc++.so.6.0.25 /usr/lib64/libstdc++.so.6
[root@jeames mysql]# mysqld --initialize
此处第3个坑
mysqld: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by mysqld) mysqld: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /lib64/libstdc++.so.6)
处理方法:
wget http://ftp.gnu.org/gnu/glibc/glibc-2.18.tar.gz tar zxf glibc-2.18.tar.gz cd glibc-2.18/ mkdir build cd build/ ##centos 升级GCC编译器 yum -y install centos-release-scl yum -y install devtoolset-8-gcc devtoolset-8-gcc-c++ devtoolset-8-binutils scl enable devtoolset-8 bash echo "source /opt/rh/devtoolset-8/enable" >>/etc/profile ##升级make wget http://ftp.gnu.org/gnu/make/make-4.2.tar.gz tar -xzvf make-4.2.tar.gz cd make-4.2 ./configure make make install rm -rf /usr/bin/make cp ./make /usr/bin/ make -v ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin make && make install 耐心等待10分钟左右
注意:以上操作之后重启服务器后然后再初始化Mysql
[root@jeames mysql]# mysqld --initialize
三、 启动Mysql
3.1 启动 mysql 服务
Step1:查看当前服务是否启动 [root@jeames ~]# ps -ef | grep mysql
[root@jeames ~]# systemctl status mysqld
[root@jeames ~]# chown mysql:mysql /var/lib/mysql -R [root@jeames ~]# systemctl start mysqld [root@jeames ~]# systemctl status mysqld [root@jeames ~]# systemctl enable mysqld [root@jeames ~]# cat /var/log/mysqld.log | grep password
3.2 创建远程用户
此处第4个坑
登录,创建新用户用以远程登录 ##动态库设置 [root@jeames ~]# mysql: error while loading shared libraries: libtinfo.so.6: cannot open shar find / -name libtinfo.so.5 ln -s libtinfo.so.6.1 libtinfo.so.6
处理过程:
find / -name libtinfo.so.5 libtinfo.so.6.1拷贝至/usr/lib64后做个快捷方式 ln -s libtinfo.so.6.1 libtinfo.so.6 libncurses.so.6拷贝至/usr/lib64即可
3.3 临时密码登陆
[root@jeames ~]# grep 'temporary password' /var/log/mysqld.log [root@jeames ~]# mysql -uroot -p
处理过程参考以下博客
Mysql8.0修改简易密码root报错处理:
https://blog.csdn.net/weixin_41645135/article/details/120588681
3.4 远程登陆
mysql> create user root@'%' identified with mysql_native_password by 'root'; mysql> grant all on *.* to root@'%' with grant option; mysql> flush privileges;