zoukankan      html  css  js  c++  java
  • centos环境下安装mysql-8.0.12

    安装包请自行在官网下载

    https://dev.mysql.com/downloads/mysql/

    一:安装相关依赖包

    yum  -y  install  gcc  gcc-c++  ncurses-devel  perl

    二:环境配置

    添加系统mysql组和mysql用户:

    groupadd mysql

    useradd -r -g mysql -s /bin/false mysql

    将mysql命令加进环境变量

    打开profile

    vim /etc/profile

    PATH=/tools/mysql-8.0.12-el7-x86_64/bin:$PATH
    export PATH

    读取profile配置

    source /etc/profile

    三:安装mysql

    解压安装包

    mysql目录结构

      

    目录目录的内容
    bin mysqld服务器,客户端和实用程序
    docs 信息格式的MySQL手册
    man Unix手册页
    include 包含(标题)文件
    lib 图书馆
    share 用于数据库安装的错误消息,字典和SQL
    support-files 其他支持文件

    修改当前目录拥有者为mysql用户:

    chown -R mysql:mysql ./

    配置mysql配置文件

    vim  /etc/my.cnf

    [client]
    port=3306 # 设置mysql客户端连接服务端时默认使用的端口

    default-character-set=utf8
    socket=/tools/mysql-8.0.12-el7-x86_64/data/mysql.sock

    [mysqld]

    basedir=/tools/mysql-8.0.12-el7-x86_64 # 设置mysql的安装目录
    datadir=/tools/mysql-8.0.12-el7-x86_64/data

    socket=/tools/mysql-8.0.12-el7-x86_64/data/mysql.sock

    # Disabling symbolic-links is recommended to prevent assorted security risks
    # symbolic-links=0
    #
    # # Settings user and group are ignored when systemd is used.
    # # If you need to run mysqld under a different user or group,
    # # customize your systemd unit file for mariadb according to the
    # # instructions in http://fedoraproject.org/wiki/Systemd
    #
    # [mysqld_safe]
    # log-error=/data/log/mysql-log/error.log
    # pid-file=/data/soft/mysql-8.0.12-el7-x86_64/data/mysql.pid
    #
    # #
    # # include all files from the config directory
    # #
    # !includedir /etc/my.cnf.d

    初始化数据目录,包括mysql包含初始MySQL授权表的 数据库,该表确定如何允许用户连接到服务器     

    bin/mysqld

    --initialize-insecure  --user=mysql    (不设置密码)

    复制启动脚本

    cp support-files/mysql.server /etc/init.d/mysql

    启动数据库

     /etc/init.d/mysql  start

    修改root密码

    进入mysql

    mysql  -u  root   -p

    ALTER USER 'root'@'localhost' IDENTIFIED BY 'passowrd' ;

    ALTER USER 'root'@'%' IDENTIFIED BY 'passowrd' ;

    flush privileges;

    MySQL8.0的用户授权和之前有所区别,老版本的常用授权语句在8.0中会报错:

    MySQL8.0之前版本:

    GRANT ALL ON *.* TO `wangwei`@`127.0.0.1` IDENTIFIED BY 'passowrd' WITH GRANT OPTION;

    MySQL8.0版本:

    CREATE USER `wangwei`@`127.0.0.1` IDENTIFIED BY 'passowrd';

    GRANT ALL ON *.* TO `wangwei`@`127.0.0.1` WITH “GRANT OPTION”;

    mysql-8.0以后的版本,用户密码认证的默认方式修改成caching_sha2_password。

    ①:此更改仅适用于安装或升级到MySQL 8.0或更高版本后创建的新帐户。对于已升级安装中已存在的帐户,其身份验证插件保持不变,还是mysql_native_password。当然也可以使用命令将用户的身份验证改为:caching_sha2_password;

    如:ALTER USER user  IDENTIFIED WITH caching_sha2_password  BY 'password';

    ②:新安装MySQL8.0的数据库默认是使用caching_sha2_password身份验证的,必须使用5.8版本安装包内的客户端软件登录数据库,如果要更改root用户的身份认证方式,可以使用命令:ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password  BY 'password';

    caching_sha2_password兼容性问题和解决方案

    如果您的MySQL安装必须服务于8.0之前的客户端,并且在升级到MySQL 8.0或更高版本后遇到兼容性问题,解决这些问题并恢复8.0之前的兼容性的最简单方法是重新配置服务器以恢复到以前的默认身份验证插件(mysql_native_password)。例如,在配置文件my.cnf中使用以下行:

    [mysqld]

    default_authentication_plugin=mysql_native_password

  • 相关阅读:
    数组和arraylist集合
    Oracle连接数据库
    c#代码转换成vb.net(互转)
    Contain方法的比较
    Linux kernel ‘ioapic_read_indirect’函数拒绝服务漏洞
    Linux Kernel Netlink Interface 多个信息泄露漏洞
    Linux kernel ‘rtnl_fill_ifinfo’函数敏感信息漏洞
    WordPress FAQs Manager插件跨站脚本和跨站请求伪造漏洞
    Linux kernel ‘MSR_KVM_SYSTEM_TIME’释放后重用漏洞
    WordPress Count Per Day插件‘counter.php’跨站请求伪造漏洞
  • 原文地址:https://www.cnblogs.com/QicongLiang/p/9812041.html
Copyright © 2011-2022 走看看