Linux安装MySQL8.0.12之二进制安装

Linux安装MySQL8.0.12之二进制安装

2018年07月29日 01:21:31 vkingnew 阅读数:6050
 
版权声明:本文为博主原创文章,转载请注明出处 https://blog.csdn.net/vkingnew/article/details/81267223
 
  1.  
    运行环境:centos+mysql8.0.12
  2.  
    1.下载官方打包好的二进制安装包:
  3.  
    #wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
  4.  
    可以看到这个版本采用了tar.xz的打包压缩方式,文件只有350M左右,下载还是满方便的。
  5.  
    # du -sh mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
  6.  
    339M mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz
  7.  
     
  8.  
    2.解压文件:
  9.  
    #tar -xJvf mysql-8.0.12-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
  10.  
    # mv /usr/local/mysql-8.0.12-linux-glibc2.12-x86_64/ /usr/local/mysql
  11.  
     
  12.  
    3.配置参数文件:
  13.  
    # cat /etc/my.cnf
  14.  
    [mysqld]
  15.  
    server-id = 1
  16.  
    port = 3306
  17.  
    mysqlx_port = 33060
  18.  
    mysqlx_socket = /tmp/mysqlx.sock
  19.  
    datadir = /data/mysql
  20.  
    socket = /tmp/mysql.sock
  21.  
    pid-file = /tmp/mysqld.pid
  22.  
    log-error = error.log
  23.  
    slow-query-log = 1
  24.  
    slow-query-log-file = slow.log
  25.  
    long_query_time = 0.2
  26.  
    log-bin = bin.log
  27.  
    relay-log = relay.log
  28.  
    binlog_format =ROW
  29.  
    relay_log_recovery = 1
  30.  
    character-set-client-handshake = FALSE
  31.  
    character-set-server = utf8mb4
  32.  
    collation-server = utf8mb4_unicode_ci
  33.  
    init_connect ='SET NAMES utf8mb4'
  34.  
    innodb_buffer_pool_size = 1G
  35.  
    join_buffer_size = 128M
  36.  
    sort_buffer_size = 2M
  37.  
    read_rnd_buffer_size = 2M
  38.  
    log_timestamps = SYSTEM
  39.  
    lower_case_table_names = 1
  40.  
    default-authentication-plugin =mysql_native_password
  41.  
     
  42.  
    4.创建目录授权等:
  43.  
    # groupadd mysql
  44.  
    # useradd mysql
  45.  
    # mkdir -p /data/mysql
  46.  
    # chown -R mysql:mysql /data/mysql/
  47.  
    # chmod -R 775 /data/mysql/
  48.  
     
  49.  
     
  50.  
    5.初始化数据库:
  51.  
    #/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql --initialize-insecure
  52.  
    官方推荐使用--initialize,会在错误日志中生成难以输入的临时密码,我这里使用的免密码的方式。
  53.  
     
  54.  
    # cat /data/mysql/error.log | grep -i password
  55.  
    2018-07-29T02:06:41.253856+08:00 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: wquR3-Kxlg1d
  56.  
     
  57.  
     
  58.  
    6.设置启动文件和环境变量:
  59.  
    #cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
  60.  
    --启动数据库:
  61.  
    # /etc/init.d/mysql start
  62.  
    Starting MySQL.Logging to '/data/mysql/error.log'.
  63.  
    SUCCESS!
  64.  
     
  65.  
    # vim /etc/profile.d/mysql.sh
  66.  
    # cat /etc/profile.d/mysql.sh
  67.  
    export PATH=$PATH:/usr/local/mysql/bin
  68.  
    # source /etc/profile.d/mysql.sh
  69.  
    # mysqld --version
  70.  
    mysqld Ver 8.0.12 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)
  71.  
    [root@node4 mysql]# /usr/local/mysql/bin/mysql -p -S /tmp/mysql.sock
  72.  
    Enter password:
  73.  
    Welcome to the MySQL monitor. Commands end with ; or \g.
  74.  
    Your MySQL connection id is 7
  75.  
    Server version: 8.0.12 MySQL Community Server - GPL
  76.  
     
  77.  
    Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
  78.  
     
  79.  
    Oracle is a registered trademark of Oracle Corporation and/or its
  80.  
    affiliates. Other names may be trademarks of their respective
  81.  
    owners.
  82.  
     
  83.  
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  84.  
     
  85.  
    mysql> select version();
  86.  
    +-----------+
  87.  
    | version() |
  88.  
    +-----------+
  89.  
    | 8.0.12 |
  90.  
    +-----------+
  91.  
    1 row in set (0.00 sec)
  92.  
    7.设置可以远程登录的账号:
  93.  
    mysql> show variables like '%valid%pass%';
  94.  
    Empty set (0.00 sec)
  95.  
     
  96.  
    mysql> create user root@'%' identified by 'oracle';
  97.  
    ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
  98.  
    mysql> show variables like '%valid%pass%';
  99.  
    ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
  100.  
    mysql> alter user root@'localhost' identified by 'oracle';
  101.  
    Query OK, 0 rows affected (0.07 sec)
  102.  
     
  103.  
    mysql> show variables like '%valid%pass%';
  104.  
    Empty set (0.01 sec)
  105.  
    --创建可以远程登录的用户:
  106.  
    mysql> create user root@'%' identified by 'oracle';
  107.  
    Query OK, 0 rows affected (0.06 sec)
  108.  
     
  109.  
    mysql> grant all privileges on *.* to root@'%' with grant option;
  110.  
    Query OK, 0 rows affected (0.07 sec)
  111.  
     
  112.  
    mysql> flush privileges;
  113.  
    Query OK, 0 rows affected (0.00 sec)
  114.  
     
  115.  
    总结:
  116.  
    官方虽然提供RPM安装方式但是不少默认参数还是不太方便平常的使用,对生产而言则需要修改更多的地方,但是很适合初级用户快速安装使用;
  117.  
    而对二进制安装包 只需要下载按照自定义的设置安装即可 方便快捷 可自主配置,适合生产布署。

转载于:https://my.oschina.net/rootliu/blog/3022248

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值