• centos7 二进制版本安装 mysql8.0.13


    一、下载mysql二进制安装包

    mysql官网:

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

    由于国内网络问题,个人建议使用国内开源镜像站下载:

    http://mirrors.163.com/mysql/Downloads/MySQL-8.0/
    http://mirrors.sohu.com/mysql/MySQL-8.0/
    http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-8.0/
    

    下载:mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz

    二、mysql依赖于libaio

    yum search libaio
    yum install libaio
    

      

    三、解压和重命名

    我们默认把mysql8安装到/data/mysql8目录下,这个目录可以随意指定。

    tar xf mysql-8.0.13-linux-glibc2.12-x86_64.tar.xz
    mv mysql-8.0.13-linux-glibc2.12-x86_64 /data/mysql8
    

      

    四、创建mysql用户名和用户组

    useradd -s /sbin/nologin -M mysql
    

      

    五、把默认/etc/my.cnf重命名或删除

    centos7默认会有一个/etc/my.cnf文件,为了不影响安装,可以直接删除或重命名。

    mv /etc/my.cnf /etc/my.cnf.bak
    

    rm /etc/my.cnf
    

      

    六、创建my.cnf文件

    cd /data/mysql8
    vi my.cnf
    

    填写如下内容:

    [mysqld]
    port = 3306
    basedir = /data/mysql8
    datadir = /data/mysql8/data
    max_connections = 1024
    character-set-server = utf8
    default-storage-engine = INNODB
    server_id = 1
    socket = /data/mysql8/mysql.sock
    pid-file = /data/mysql8/mysql.pid
    slow_query_log = 1
    slow_query_log_file = /data/mysql8/log/mysql-slow.log
    long_query_time = 10
    log-error = /data/mysql8/log/mysql-err.log
    log-bin = /data/mysql8/log/mysql-bin
    user = mysql 
    default_authentication_plugin = mysql_native_password
    
    sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
     
    [mysql]
    default-character-set = utf8
     
    [client]
    port = 3306
    socket = /data/mysql8/mysql.sock
    default-character-set = utf8
    

    创建一个软链接

    ln -s /data/mysql8/my.cnf /etc/my.cnf
    

      

    七、创建目录,修改目录所有者,初始化mysql数据库

    mkdir /data/mysql8/log
    mkdir /data/mysql8/data
    chown -R mysql.mysql /data/mysql8
    /data/mysql8/bin/mysqld --initialize --user=mysql --basedir=/data/mysql8 --datadir=/data/mysql8/data
    

      

    八、把启动文件复制到/etc/init.d/目录下

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

    修改46,47行的basedir和datadir

    basedir= /data/mysql8
    datadir= /data/mysql8/data

    修改63-82行,把路径改成自已的mysql安装路径

    mysqld_pid_file_path=
    if test -z "$basedir"
    then
      basedir=/data/mysql8
      bindir=/data/mysql8/bin
      if test -z "$datadir"
      then
        datadir=/data/mysql8/data
      fi
      sbindir=/data/mysql8/bin
      libexecdir=/data/mysql8/bin
    else
      bindir="$basedir/bin"
      if test -z "$datadir"
      then
        datadir="$basedir/data"
      fi
      sbindir="$basedir/sbin"
      libexecdir="$basedir/libexec"
    fi
    

      

    九、启动mysql服务

    service mysql start
    

      

    十、登陆mysql,修改root用户密码

    mysql初始化时会自动生成一个密码,可以在log-error指定的错误日志中查看

    mysql -u root -p
    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
    flush privileges;
    

      

    十一、创建可远程连接的用户

    create user '用户名'@'主机' identified with mysql_native_password by '密码';
    grant all privileges on *.* to '用户名'@'主机';
    flush privileges;
    

      

    十二、添加环境变量

    vi /etc/profile
    

    添加如下内容:

    export PATH=$PATH:/data/mysql8/bin
    

    使配置生效

    source /etc/profile
    

      

  • 相关阅读:
    (4.24~4.30)
    (4.17~4.23)
    (4.10~4.16)
    FFT题集
    kd树的构造与搜索
    schtasks命令
    关于[WinError 10054] 远程主机强迫关闭了一个现有的连接。
    数据去重复
    将ppt文档转换成pdf
    mvc上传
  • 原文地址:https://www.cnblogs.com/jkko123/p/10162721.html
Copyright © 2020-2023  润新知