zoukankan      html  css  js  c++  java
  • CentOS下mysql忘记root密码解决办法,centOS7中Host is not allowed to connect

    1,停止mysql服务命令            

    systemctl stop mysqld

            2,修改配置文件/etc/my.cnf

                在[mysqld]下添加

               skip-grant-tables

                意思是忽略验证,保存并退出

            3,启动Mysql命令            

    systemctl start mysqld

             4,修改密码

                执行命令:mysql

                Welcome to the MySQL monitor. Commands end with ; or g.

                Your MySQL connection id is 3 to server version: 3.23.56
                Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
                mysql> USE mysql ;
                Database changed
                mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ;
                Query OK, 0 rows affected (0.00 sec)
                Rows matched: 2 Changed: 0 Warnings: 0
                mysql> flush privileges ;
                Query OK, 0 rows affected (0.01 sec)

                mysql> quit

            5,改回配置 :删除 /etc/my.cnf 文件中的 skip-grant-tables,重启服务

                systemctl restart mysqld

    centOS7中Host is not allowed to connect to this MySQL server解决方法

    原因是Centos不允许远程登录mysql

    解决办法:

    登录 MySQL,执行:mysql -u root -p  (输入密码)
    执行: use mysql
    执行: update user set host ='%' where user = 'root'; 执行会报错,不影响结果 (如果你不是root登录,修改成你需要的账号)
    执行: flush privileges;

  • 相关阅读:
    (转)CMD指令大全
    [转]测试人员要像医生一样把要测试的程序当自己的病人一样看待一样检测!
    robotFramework学习笔记
    mysql数据库转换成数据字典的方法(整理)
    【转】PHP SQL防注入的一些经验
    性能测试基础知识(概念)
    iOS--MJRefresh的使用 上拉刷新和下拉加载
    IOS----UIScrollerView的使用
    iOS -- UILabel的高度自适应
    第二章 图像形成
  • 原文地址:https://www.cnblogs.com/q149072205/p/12850315.html
Copyright © 2011-2022 走看看