zoukankan      html  css  js  c++  java
  • rhel_6.x 安装mysql

    不知为何mysql的官网很难下载,本人网上找了好久,终于找到了个镜像:

    特别感谢http://mirrors.sohu.com/mysql/MySQL-5.6/    ^_^

    首先下载mysql的下面三个RHEL6安装包:(可以直接下个MySQL-5.6.22-1.el6.x86_64.rpm-bundle.tar)
    MySQL-client-5.6.22-1.el6.x86_64.rpm
    MySQL-devel-5.6.22-1.el6.x86_64.rpm
    MySQL-server-5.6.22-1.el6.x86_64.rpm
    然后使用root账号登陆,进行安装:


    1. 安装server、devel、client:

    rpm -ivh --replacefiles MySQL-s*.rpm
    rpm -ivh --replacefiles MySQL-d*.rpm
    rpm -ivh --replacefiles MySQL-c*.rpm

    2. 初始化数据库:

    /usr/bin/mysql_install_db
    3. 启动mysql服务:

    service mysql start
    4.第一次登陆设置root密码:
    首先查看 cat /root/.mysql_secret
    # mysql -u root -p
    Enter password:

    mysql> set password=password('admin');
    Query OK, 0 rows affected (0.00 sec)

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

    5. 设置远程登陆:
    mysql> use mysql;

    mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'admin' WITH GRANT OPTION;
    mysql> FLUSH PRIVILEGES;

    mysql> exit;

    //取消防火墙的ftp拦截
    # iptables -L -n //查看
    # system-config-firewall
    # mysql -h 192.168.*.* -P 3306 -u root -padmin

    6. 设置随开机启动
    # chkconfig --add mysql
    # chkconfig --level 35 mysql on
    # service mysql restart

    GOOD!

    忘记root密码怎么办:

    介绍一个非常有用的mysql启动参数—— --skip-grant-tables。 顾名思义,就是在启动mysql时不启动grant-tables,授权表。有什么用呢?当然是忘记管理员密码后有用。
        操作方法:
        1、杀掉原来进行着的mysql:
           rcmysqld stop
           或者:
           service mysqld stop
           或者:
           kill -TERM mysqld
        2、以命令行参数启动mysql:
           /usr/bin/mysqld_safe --skip-grant-tables &
        3、修改管理员密码:
           use mysql;
           update user set password=password('yournewpasswordhere') where user='root';

           update mysql.user set authentication_string=password('admin') where user='root' ;
           flush privileges;
           exit;
        4、杀死mysql,重启mysql

  • 相关阅读:
    Windows 7 X64位平台下,VC6调试运行程序,中断调试无法退出
    在Windows中安装MinGW-w64(有图,一步一步)
    自我修养
    Core 事件总
    异步消息
    微信小程序
    安装Zookeeper集群
    Linux删除非空目录
    adoop集群动态添加和删除节点
    安装和配置hadoop集群步骤
  • 原文地址:https://www.cnblogs.com/book-gary/p/4211361.html
Copyright © 2011-2022 走看看