1. 卸载mariadb # 一般centos7会默认安装mariadb, 新安装的mysql8会与它造成依赖冲突,可以按下列方式进行卸载: rpm -qa | grep mariadb #如果出现 mariadb-libs-5.5.68-1.el7.x86_64 #执行 rpm -e mariadb-libs --nodeps 我使用的是阿里云轻量级ECS服务器,没有安装mariadb 2. 下载mysql8的rpm文件(目前这个链接是可用的) wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.31-1.el7.x86_64.rpm-bundle.tar #下载完成后创建目标文件夹,将其解压 cd /opt mkdir mysql tar -xvf mysql-8.0.31-1.el7.x86_64.rpm-bundle.tar -C /opt/mysql #然后会出现以下几个安装包 mysql-community-client-8.0.31-1.el7.x86_64.rpm mysql-community-client-plugins-8.0.31-1.el7.x86_64.rpm mysql-community-common-8.0.31-1.el7.x86_64.rpm mysql-community-debuginfo-8.0.31-1.el7.x86_64.rpm mysql-community-devel-8.0.31-1.el7.x86_64.rpm mysql-community-embedded-compat-8.0.31-1.el7.x86_64.rpm mysql-community-icu-data-files-8.0.31-1.el7.x86_64.rpm mysql-community-libs-8.0.31-1.el7.x86_64.rpm mysql-community-libs-compat-8.0.31-1.el7.x86_64.rpm mysql-community-server-8.0.31-1.el7.x86_64.rpm mysql-community-server-debug-8.0.31-1.el7.x86_64.rpm mysql-community-test-8.0.31-1.el7.x86_64.rpm 3. 安装 yum install -y perl.x86_64 rpm -ivh mysql-community-common-8.0.31-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-8.0.31-1.el7.x86_64.rpm rpm -ivh mysql-community-client-8.0.31-1.el7.x86_64.rpm rpm -ivh mysql-community-server-8.0.31-1.el7.x86_64.rpm 4、安装openssl openssl官网为https://www.openssl.org/source/,找到需要下载的openssl版本,这里选择最新 openssl-1.1.1s.tar.gz 版本 # 下载openssl cd /usr/local wget https://www.openssl.org/source/openssl-1.1.1s.tar.gz 如果提示 To connect to www.openssl.org insecurely, use `--no-check-certificate'. 则使用以下命令: wget https://www.openssl.org/source/openssl-1.1.1s.tar.gz --no-check-certificate # 安装openssl tar -xzvf openssl-1.1.1s.tar.gz cd openssl-1.1.1s # 将安装文件的路径指定为/usr/local/openssl 目录 ./config --prefix=/usr/local/openssl # 在指定的 /usr/local/openssl目录下安装openssl make && make install # 如果openssl路径不对,也可以使用软连接 ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl # 查看openssl当前版本 openssl version # 将openssl添加到动态库的环境变量 vim /etc/ld.so.conf 添加以下内容,然后保存退出 /usr/local/openssl/lib # 应用配置 ldconfig /etc/ld.so.conf 5、安装gcc 如果安装openssl的时候系统提示没有gcc:未找到gcc命令 或 gcc not found / gcc not exist 这时执行: yum install gcc 安装好后重新执行 make && make install 安装openssl 6、mysql8安装失败卸载 # 查询安装 rpm -qa | grep -i mysql # 卸载mysql #使用rpm -e 命令卸载mysql安装包 # 删除mysql相关的服务 chkconfig --list | grep -i mysql chkconfig --del mysql # 删除系统中分散的mysql文件夹 find / -name mysql # 清空mysql相关的所有目录以及文件 rm -rf 7、启动 # 启动 systemctl start mysqld # 查看启动状态 systemctl status mysqld 8、修改密码 # 查看初始密码 grep 'temporary password' /var/log/mysqld.log # 使用日志中查询到的密码登录 mysql -uroot -p # 如果需要使用简单密码,首先需要将密码修改成复杂密码 ALTER USER 'root'@'localhost' IDENTIFIED BY 'AB!@#¥%&'; # 调整MySQL8密码验证规则: set global validate_password.policy=0; set global validate_password.length=1; 如果不修改密码,执行上面命令会提示: ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. # 再次将密码修改成简单密码 ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; # 刷新权限 GRANT ALL PRIVILEGES ON *.* TO 'root'@'local' WITH GRANT OPTION; FLUSH PRIVILEGES; 9、设置mysql远程连接 用软件登陆Mysql8数据库时,会报错:Authentication plugin 'caching_sha2_password' cannot be loaded。 出现这个原因是mysql8之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password。 解决问题方法有两种,一种是升级客户端驱动, 另一种是把mysql用户登录密码加密规则还原成mysql_native_password。简单起见我们采用第二种,修改加密规则: 1、登录Mysql: mysql -u root -p # 修改加密规则, ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; # 更新一下用户的密码 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456'; 2、 修改用户root的localhost为‘%’ update user set host = '%' where user = 'root' and host='localhost'; 3、重置密码 alter user 'root'@'%' identified WITH mysql_native_password by '123456'; 4、刷新权限 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; FLUSH PRIVILEGES; 最后最好重启一次mysql 安装mysql经常遇到的问题 一、mysql8 error while loading shared libraries: libssl.so.10: cannot open shared object https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/compat-openssl10-1.0.2o-3.el8.x86_64.rpm 在centos安装mysql8的过程中,提示报错mysql: error while loading shared libraries: libssl.so.10: cannot open shared object file: No such file or directory; 安装compat-openssl10-1.0.2o-3.el8.x86_64 下载地址:https://centos.pkgs.org/8/centos-appstream-x86_64/compat-openssl10-1.0.2o-3.el8.x86_64.rpm.html rpm -ivh compat-openssl10-1.0.2o-3.el8.x86_64.rpm
标签:x86,centos,mysql8,openssl,64,mysql,rpm,el7,搭建 From: https://www.cnblogs.com/weitinting/p/17177717.html