MySQL 官网下载安装包图文

  1. mysql官网downloads(https://www.mysql.com/downloads/)
  2. 选择社区版 alt
  3. 选择MySQL community server alt
  4. 选择要下载的版本,如何想下载历史版本,点击 archives alt
  5. 选择RMP Bundle进行下载 alt
  6. 跳过注册或者登录,直接下载 alt

利用安装包进行安装的过程

  1. 解压安装包
tar -xvf mysql-5.7.34-1.el7.x86_64.rpm-bundle.tar
  1. 通过以下命令安装
rpm -ivh mysql-community-common-5.7.34-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.34-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.34-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.34-1.el7.x86_64.rpm

rpm -ivh mysql-community-libs-compat-5.7.34-1.el7.x86_64.rpm
rpm -ivh mysql-community-embedded-compat-5.7.34-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.34-1.el7.x86_64.rpm

在执行命令

rpm -ivh mysql-community-client-5.7.34-1.el7.x86_64.rpm

出现 error

warning: mysql-community-client-5.7.34-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
        libncurses.so.5()(64bit) is needed by mysql-community-client-5.7.34-1.el7.x86_64
        libtinfo.so.5()(64bit) is needed by mysql-community-client-5.7.34-1.el7.x86_64

解决方案:

yum install libncurses*
yum install libtinfo*

在执行命令

rpm -ivh mysql-community-libs-compat-5.7.34-1.el7.x86_64.rpm

遇到以下 error

warning: mysql-community-libs-compat-5.7.34-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
        libcrypto.so.10()(64bit) is needed by mysql-community-libs-compat-5.7.34-1.el7.x86_64
        libcrypto.so.10(libcrypto.so.10)(64bit) is needed by mysql-community-libs-compat-5.7.34-1.el7.x86_64
        libssl.so.10()(64bit) is needed by mysql-community-libs-compat-5.7.34-1.el7.x86_64
        libssl.so.10(libssl.so.10)(64bit) is needed by mysql-community-libs-compat-5.7.34-1.el7.x86_64

解决方案:

 dnf install compat-openssl10
  1. 初始化 MySQL 服务
mysqld --initialize
  1. 生成MySQL用户组
grep mysql /etc/group
grep mysql /etc/passwd
  1. 修改目录权限
chown mysql:mysql /var/lib/mysql -R

  1. 启动服务
systemctl start mysqld
systemctl enable mysqld
systemctl status mysqld
  1. 获取 MySQL 初始密码
cat /var/log/mysqld.log | grep passowrd
  1. 修改初始密码
alter user 'root'@'localhost' identified by 'new password';