• Centos7离线安装mysql8


    linux版本:Centois7

    mysql版本:mysql-8.0.16

    一、安装

    1、下载mysql离线安装包

    下载地址:https://dev.mysql.com/downloads/mysql/

    选择如下:

    【Red Hat Enterprise Linux 7 / Oracle Linux】

    【Red Hat Enterprise Linux 7 / Oracle Linux 7 (x86, 64-bit)】

    2、上传tar包至服务器

    3、删除原有的mariadb

    先查看一下是否已经安装了,命令:rpm -qa|grep mariadb

    删除mariadb,命令:rpm -e --nodeps mariadb-libs

    4、解压缩mysql离线安装包

    cd /home/soft

    tar -xvf mysql-8.0.16-2.el7.x86_64.rpm-bundle.tar

    解压缩之后,包含以下rpm包

    mysql-community-libs-8.0.16-2.el7.x86_64.rpm
    mysql-community-embedded-compat-8.0.16-2.el7.x86_64.rpm
    mysql-community-devel-8.0.16-2.el7.x86_64.rpm
    mysql-community-server-8.0.16-2.el7.x86_64.rpm
    mysql-community-libs-compat-8.0.16-2.el7.x86_64.rpm
    mysql-community-client-8.0.16-2.el7.x86_64.rpm
    mysql-community-common-8.0.16-2.el7.x86_64.rpm
    mysql-community-test-8.0.16-2.el7.x86_64.rpm

    5、安装rmp包

    逐个安装,命令如下:

    【必须安装】

    rpm -ivh mysql-community-common-8.0.16-2.el7.x86_64.rpm

    rpm -ivh mysql-community-libs-8.0.16-2.el7.x86_64.rpm

    rpm -ivh mysql-community-client-8.0.16-2.el7.x86_64.rpm

    rpm -ivh mysql-community-server-8.0.16-2.el7.x86_64.rpm

    【非必须安装】

    rpm -ivh mysql-community-libs-compat-8.0.16-2.el7.x86_64.rpm

    rpm -ivh mysql-community-embedded-compat-8.0.16-2.el7.x86_64.rpm

    rpm -ivh mysql-community-devel-8.0.16-2.el7.x86_64.rpm

    rpm -ivh mysql-community-test-8.0.16-2.el7.x86_64.rpm

    出现错误1:

    warning: mysql-community-devel-8.0.16-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    error: Failed dependencies:
        pkgconfig(openssl) is needed by mysql-community-devel-8.0.16-2.el7.x86_64

    解决办法1:

    yum install openssl-devel.x86_64 openssl.x86_64 -y

    出现问题2:

    warning: mysql-community-test-8.0.16-2.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
    error: Failed dependencies:
        perl(Data::Dumper) is needed by mysql-community-test-8.0.16-2.el7.x86_64
        perl(JSON) is needed by mysql-community-test-8.0.16-2.el7.x86_64

    解决办法2:

    yum install perl.x86_64 perl-devel.x86_64 -y

    yum install perl-JSON.noarch -y

    yum -y install autoconf

    二、服务启停

    1、查看服务状态

    命令:systemctl status mysqld

    2、停止服务

    命令:service mysqld stop

    3、初始化数据库

    命令:mysqld --initialize --console

    4、目录授权

    命令:chown -R mysql:mysql /var/lib/mysql/

    5、启动mysql服务

    命令:systemctl start mysqld

    命令:systemctl status mysqld

    三、数据库操作

    1、查看临时密码:

    命令:cat /var/log/mysqld.log

    2、用临时密码登录数据库

    命令:mysql -u root -p 回车键

    然后输入临时密码(输入时不会显示出来,输入完直接回车)

    3、修改mysql密码

     

     

    命令:alter USER 'root'@'localhost' IDENTIFIED BY '123456';

    4、授权远程连接

    命令:show databases;

    命令:use mysql;

    命令:select host, user, authentication_string, plugin from user;

    命令:update user set host = "%" where user='root';

    命令:select host, user, authentication_string, plugin from user;

    命令:flush privileges;

    尝试使用navacat远程连接,会出现如下错误

    2059 - Authenticationplugin‘caching_sha2_password’ cannot be loaded:XXXXX

    解决办法:

    命令:mysql -u root -p(回车后,输入更改后的密码123456)

    命令:use mysql;

    命令:alter USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';

    命令:flush privileges;

    备注:
    mysql8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是caching_sha2_password。
    解决问题方法有两种:
    方法1.升级navicat驱动;
    方法2.把mysql用户登录密码加密规则还原成mysql_native_password.。
    此处我使用的是方法2。

    再次从navicat尝试连接mysql,测试成功。

    四、在阿里云ECS云服务器上再次进行安装时遇到的问题

    阿里云ECS系统环境:Centos8

    ==问题1==

    在执行rpm -ivh rpm -ivh mysql-community-libs-8.0.16-2.el7.x86_64.rpm的时候,报错如下:

    解决办法:

    下载并安装compat-openssl10-1.0.2o-3.el8.x86_64.rpm

    ==问题2==

    在执行rpm -ivh mysql-community-server-8.0.16-2.el7.x86_64.rpm之后,报如下错误;

    解决办法:

    按照提示,修改文件中的路径之后,重新执行rpm命令即可

    vim /usr/lib/tmpfiles.d/libstoragemgmt.conf

    vim /usr/lib/tmpfiles.d/mysql.conf

    vim /usr/lib/tmpfiles.d/mdadm.conf

    ==问题3==

    使用命令systemctl start mysqld启动mysql的时候,启动失败,通过cat /var/log/mysqld.log命令查看日志,发现以下错误

    The innodb_system data file 'ibdata1' must be writable

    解决办法:

    修改目录权限。命令:chmod -R 777 /var/lib/mysql

    --END--

  • 相关阅读:
    macOS 上配置 Lua
    Oracle.ManagedDataAccess.dll
    offer
    Costura.Fody
    日志系统
    实战框架ABP
    什么是算法?
    HTTP状态码->HTTP Status Code
    How to untar a TAR file using Apache Commons
    python实践3:cursor() — 数据库连接操作
  • 原文地址:https://www.cnblogs.com/quchunhui/p/11115339.html
Copyright © 2020-2023  润新知