zoukankan      html  css  js  c++  java
  • windows下本地连接MYSQL数据库,报1130错误的解决方法

    重装MySQL,使用重装之后的密码连接Mysql数据,总报 ERROR 1130: host 'localhost' not allowed to connect to this MySQLserver,不能连接数据库,猜测用户权限和密码的问题。

    1、用root用户登录mysql数据库

    (1)停止MySQL服务,执行net stop mysql;

    (2)在mysql的安装路径下找到配置文件my.ini,

       找到[mysqld]
       输入:skip-grant-tables,保存

    (3)重启mysql服务,net start mysql;

    (4)执行mysql -uroot -p,回车,再回车,即可进入mysql数据库;

     

    2、在本机登入mysql后,更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost”改称'%'。

    mysql>use mysql;

    mysql>select host,user,password from user;

    mysql>update user set host = '%' where user ='root';

    mysql>flush privileges;    #刷新用户权限表

    mysql>select host,user,password  from user where user='root';

    3、修改root密码

    (1)用set password 方式修改root密码遇到错误ERROR 1290 (HY000)

    mysql> set password for root@'localhost'=PASSWORD('12345');
    ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot exe
    cute this statement

    注意:以skip-grant-tables方式启动mysql后,不能用直接用set password的方式修改root密码,须注释skip-grant-tables, 然后重启服务,连接数据库修改密码

    (2)用update方式修改root密码正常

    mysql> update user set password=password("123") where user="root";

    mysql>flush privileges; 

     (3)不连接数据库,直接在cmd下修改密码

    mysqladmin -uroot -p旧密码 password 新密码,此种方式修改密码也不能在以“skip-grant-tables“方式启动mysql后进行

    如:mysqladmin -uroot -p123456 password 1234

    5、退出MySQL,在配置文件中注释:skip-grant-tables,重启mysql服务

    6、本地重新连接mysql数据库,输入修改后的密码,连接成功

     

     

    参考博客:https://blog.csdn.net/Txwillnottleaveyou/article/details/80201570

  • 相关阅读:
    又是一年叶落时(二)
    动态规划 之 区间DP练习
    [hdu2255] 奔小康赚大钱
    [洛谷P1967] 货车运输
    [UVA1494] Qin Shi Huang's National Road System
    斜率优化总结
    latex一些有用的写法
    [YTU]_2384 ( 矩形类中运算符重载【C++】)
    [YTU]_2442( C++习题 矩阵求和--重载运算符)
    [YTU]_2640( 编程题:运算符重载---矩阵求和)
  • 原文地址:https://www.cnblogs.com/xingyuner/p/12795956.html
Copyright © 2011-2022 走看看