• linux下安装mysql8.0(二进制方式)


    环境

    OS:Centos 7

    1.下载安装介质
    官网下载
    我这里下载的是8.0.17
    mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz

    2.创建mysql用户和用户组
    #groupadd mysql
    #useradd -g mysql mysql
    #passwd mysql

    3.下载解压安装
    [root@localhost soft]# tar -xvf mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz
    [root@localhost soft]# mv mysql-8.0.17-linux-glibc2.12-x86_64 /opt/mha/mysql8

    4.创建相应的目录
    [root@localhost mysql8]# mkdir data ##数据文件目录
    [root@localhost mysql8]# mkdir conf ## 配置文件目录
    [root@localhost mysql8]# mkdir redolog ##redo日志文件
    [root@localhost mysql8]# mkdir -p mysqllog/relaylog ##主从环境relaylog
    [root@localhost mysql8]# mkdir -p mysqllog/logfile ##错误日志文件
    [root@localhost mysql8]# mkdir -p mysqllog/binlog ##binlog文件
    [root@localhost mysql8]# mkdir ibdata ##ibdata文件


    5.初始化数据库
    root账户下
    [root@localhost bin]# ./mysqld --initialize --user=mysql --basedir=/opt/mha/mysql8 --datadir=/opt/mha/mysql8/data
    2019-09-05T08:25:17.210466Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
    2019-09-05T08:25:17.210613Z 0 [System] [MY-013169] [Server] /opt/mha/mysql8/bin/mysqld (mysqld 8.0.17) initializing of server in progress as process 25951
    2019-09-05T08:25:38.288278Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: vew-DWj=q4r<
    2019-09-05T08:25:49.555673Z 0 [System] [MY-013170] [Server] /opt/mha/mysql8/bin/mysqld (mysqld 8.0.17) initializing of server has complete

    这里初始化密码为vew-DWj=q4r<

    若不想要初始化密码,不需要密码的话可以采用如下方法初始化话
    ./mysqld --initialize-insecure --user=mysql --basedir=/opt/mha/mysql8 --datadir=/opt/mha/mysql8/data

    6.配置文件
    vi /opt/mha/mysql8/conf/my.cnf
    [mysqld]
    server-id=134
    port=13306
    basedir=/opt/mha/mysql8
    datadir=/opt/mha/mysql8/data
    socket=/opt/mha/mysql8/mysql.sock
    character-set-server=utf8mb4
    max_connections = 1500
    binlog_format=row
    log-bin=/opt/mha/mysql8/mysqllog/binlog/binlog
    slow_query_log_file=/opt/mha/mysql8/mysqllog/logfile/slow-query.log
    log-error=/opt/mha/mysql8/mysqllog/logfile/mysql-err.log
    relay-log-index=/opt/mha/mysql8/mysqllog/relaylog/slave-relay-bin.index
    relay-log=/opt/mha/mysql8/mysqllog/relaylog/relaylog-binlog
    gtid_mode=ON
    enforce_gtid_consistency = ON
    event_scheduler=1


    7.修改目录权限
    [root@localhost mha]# cd /opt
    [root@localhost opt]# chown -R mysql:mysql ./mha


    8.启动
    (在mysql用户下执行)
    [mysql@localhost bin]$ /opt/mha/mysql8/bin/mysqld_safe --defaults-file=/opt/mha/mysql8/conf/my.cnf --user=mysql &

    9.登陆数据库修改相应用户密码
    [mysql@localhost bin]$ ./mysql -h 127.0.0.1 -uroot -P13306 -S /opt/mha/mysql8/mysql.sock -p

    mysql> select version();
    ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

    提示修改密码
    alter user 'root'@'localhost' identified by 'mysql';
    flush privileges;

    10.重新登录
    [mysql@localhost bin]$ ./mysql -h localhost -uroot -P13306 -S /opt/mha/mysql8/mysql.sock -pmysql

    mysql> select version();
    +-----------+
    | version() |
    +-----------+
    | 8.0.17 |
    +-----------+
    1 row in set (0.00 sec)

    11.创建开发用户
    在mysql8.0创建用户和授权和之前不太一样了,其实严格上来讲,也不能说是不一样, 只能说是更严格, mysql8.0需要先创建用户(创建用户时要带@并指定地址, 则grant授权时的地址就是这个@后面指定的!, 否则grant授权就会报错!)和设置密码,然后才能授权。
    create user 'hxl'@'%' identified by 'mysql';
    grant all privileges on *.* to 'hxl'@'%' with grant option;

    采用5.7之前的办法创建用户会报错
    mysql> grant all privileges on *.* to 'hxl01'@'%' identified by 'mysql';
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'mysql'' at line 1

  • 相关阅读:
    poj2478
    poj2376
    poj2192
    poj1062
    [HDOJ2639]Bone Collector II(第k优01背包)
    [HDOJ3466]Proud Merchants(贪心+01背包)
    [HDOJ5510]Bazinga(并查集)
    [POJ3264]Balanced Lineup(线段树,区间最值差)
    [HDOJ4325]Flowers(树状数组 离散化)
    [HDOJ5521]Meeting(最短路)
  • 原文地址:https://www.cnblogs.com/hxlasky/p/11468461.html
Copyright © 2020-2023  润新知