• RHEL6.5安装MySQL8.0


    之前曾经写过关于RHEL6.5的安装还有网络yum的配置不会的请参考以下两篇文章

    系统安装https://www.cnblogs.com/lch1990/p/10310304.html

    yum配置https://www.cnblogs.com/lch1990/p/10299714.html

    好了既然要装mysql我们就去mysql官网下载最新的安装包吧

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

    这里就不登录仅下载了

    或者你可以将此处的链接复制出来直接在RHEL上面wget一下直接上命令吧

    [root@localhost ~]# mkdir /download
    [root@localhost ~]# cd /download/
    [root@localhost download]# yum -y install wget

    略过安装过程。。。

    [root@localhost download]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.14-1.el6.x86_64.rpm-bundle.tar

    略过下载过程。。。

    解压安装吧

    [root@localhost download]# ls
    mysql-8.0.14-1.el6.x86_64.rpm-bundle.tar
    [root@localhost download]# tar -xf mysql-8.0.14-1.el6.x86_64.rpm-bundle.tar
    [root@localhost download]# ll
    total 1054088
    -rw-r--r--. 1 root root 539688960 Dec 21 22:46 mysql-8.0.14-1.el6.x86_64.rpm-bundle.tar
    -rw-r--r--. 1 7155 31415 28906092 Dec 21 22:02 mysql-community-client-8.0.14-1.el6.x86_64.rpm
    -rw-r--r--. 1 7155 31415 705796 Dec 21 22:02 mysql-community-common-8.0.14-1.el6.x86_64.rpm
    -rw-r--r--. 1 7155 31415 4258896 Dec 21 22:02 mysql-community-devel-8.0.14-1.el6.x86_64.rpm
    -rw-r--r--. 1 7155 31415 2542980 Dec 21 22:03 mysql-community-libs-8.0.14-1.el6.x86_64.rpm
    -rw-r--r--. 1 7155 31415 1769300 Dec 21 22:03 mysql-community-libs-compat-8.0.14-1.el6.x86_64.rpm
    -rw-r--r--. 1 7155 31415 414593048 Dec 21 22:03 mysql-community-server-8.0.14-1.el6.x86_64.rpm
    -rw-r--r--. 1 7155 31415 86904716 Dec 21 22:04 mysql-community-test-8.0.14-1.el6.x86_64.rpm

    接下来就开始安装吧,这里提供一个非常简单的方法一条命令搞定

    [root@localhost download]# yum -y install mysql-community-*

    你没看错就这一条命令然后就静等yum为你解决一切依赖关系吧

    [root@localhost download]# service mysqld status
    mysqld is stopped
    [root@localhost download]# service mysqld start
    Starting mysqld: [ OK ]

    不错服务成功启动了说明安装没问题了继续往下吧

    修改MySQL配置文件:vim /etc/my.cnf,在文件末尾加上:skip-grant-tables,保存后重启MySQL服务:service mysqld restart,然后重新登录

    [root@localhost download]# cat /etc/my.cnf
    # For advice on how to change settings please see
    # http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

    [mysqld]
    #
    # Remove leading # and set to the amount of RAM for the most important data
    # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    # innodb_buffer_pool_size = 128M
    #
    # Remove the leading "# " to disable binary logging
    # Binary logging captures changes between backups and is enabled by
    # default. It's default setting is log_bin=binlog
    # disable_log_bin
    #
    # Remove leading # to set options mainly useful for reporting servers.
    # The server defaults are faster for transactions and fast SELECTs.
    # Adjust sizes as needed, experiment to find the optimal values.
    # join_buffer_size = 128M
    # sort_buffer_size = 2M
    # read_rnd_buffer_size = 2M
    #
    # Remove leading # to revert to previous value for default_authentication_plugin,
    # this will increase compatibility with older clients. For background, see:
    # https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
    # default-authentication-plugin=mysql_native_password

    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock

    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
    skip-grant-tables
    [root@localhost download]# service mysqld restart
    Stopping mysqld: [ OK ]
    Starting mysqld: [ OK ]
    [root@localhost download]#

    接下来我们就可以登录了(首次登录没有密码直接回车)

    [root@localhost download]# mysql -u root -p
    Enter password:
    Welcome to the MySQL monitor. Commands end with ; or g.
    Your MySQL connection id is 8
    Server version: 8.0.14 MySQL Community Server - GPL

    Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.

    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

    mysql>

    下面就发挥你的想象尽情的玩耍吧!!

    mysql> alter user'root'@'%' IDENTIFIED BY '123456';
    ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
    mysql> flush privileges;
    Query OK, 0 rows affected (0.06 sec)

    mysql> ALTER user 'root'@'localhost' IDENTIFIED BY '123456';
    Query OK, 0 rows affected (0.04 sec)

    额这个我也没想到多次尝试才发现,居然只需要刷新一下权限就可以进行修改了。那么既然修改成功了为了安全起见那我们就吧配置文件中的skip-grant-tables删掉并重启服务吧

    mysql> flush privileges;
    Query OK, 0 rows affected (0.05 sec)

    mysql> GRANT ALL ON *.* TO 'root'@'%';
    ERROR 1410 (42000): You are not allowed to create a user with GRANT
    mysql> CREATE USER 'root'@'%' IDENTIFIED BY '123456';
    Query OK, 0 rows affected (0.06 sec)

    mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
    Query OK, 0 rows affected (0.03 sec)

    mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
    Query OK, 0 rows affected (0.02 sec)

    mysql> flush privileges;
    Query OK, 0 rows affected (0.01 sec)

    到这里授权就算搞定了要想连接还需要配置防火墙我这里就直接关闭防火墙了

    [root@localhost ~]# service iptables stop
    iptables: Setting chains to policy ACCEPT: filter [ OK ]
    iptables: Flushing firewall rules: [ OK ]
    iptables: Unloading modules: [ OK ]

    下面就是用工具测试一下吧

    OK我们可以用连接工具连接了,注意我这里授权的是Navicat连接如需要其他工具连接需要给对应的授权哦

  • 相关阅读:
    git 查看远程分支、本地分支、创建分支、把分支推到远程repository、删除本地分支
    bootstrap-glyphicons图标
    linux下批量替换文件夹下某个字符串
    php 按照图片名下载图片到对应文件夹
    win7设置电脑定时关机
    转 Nginx+FastCGI到底是谁影响超时时间
    linux添加系统负载日志
    PHP计划任务:如何使用Linux的Crontab执行PHP脚本(转载)
    ubuntu php执行计划任务
    phpStudy:使用localhost无法访问的解决方案
  • 原文地址:https://www.cnblogs.com/lch1990/p/10313116.html
Copyright © 2020-2023  润新知