zoukankan      html  css  js  c++  java
  • windows下新安装的mysql修改root password问题

    常用步骤:

    1. 在my.ini中的mysqld下添加一行 

         skip-grant-tables

    2.重启mysql后直接进入后,用SQL直接修改password列:

    C:> net stop mysql
    C:> net start mysql
    C:> mysql
    mysql>
    mysql> use mysql
    Database changed
    mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
    ERROR 1054 (42S22): Unknown column 'Password' in 'field list'

    3. 但失败了,原因是新版的mysql(5.7以后版本)这个列已经改成了"authentication_string", 所以在会失败,正确的做法是

    mysql> UPDATE user SET authentication_string=PASSWORD('newpassword') where USER='root';
    Query OK, 1 row affected, 1 warning (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 1
    
    mysql>

    4. 从my.ini中去掉之前加入的skip-grant-tables那行, 然后重启mysql后,就可以用带password的root登录了

    E:mysql>net stop mysql
    MySQL 服务正在停止.
    MySQL 服务已成功停止。
    
    
    E:mysql>net start mysql
    MySQL 服务正在启动 .
    MySQL 服务已经启动成功。
    
    
    E:mysql>mysql -u root -p
    Enter password: ***********
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.7.15
    
    Copyright (c) 2000, 2016, 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>

    5. 这个时候还没完,你还需要在正常模式下再修改一次密码,否则啥也做不了,如下错误:

    mysql> use mysql
    ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

    5. 而且提示很坑爹, 你必须用SET_PASSWORD, 而不是提示所说的ALTER USER

    mysql> SET PASSWORD = PASSWORD('newpassword');
    Query OK, 0 rows affected, 1 warning (0.00 sec)
    
    mysql>use mysql
    mysql>Database changed
  • 相关阅读:
    servlet
    过滤器
    拦截器
    logback
    hibernate(1)
    函数的关键字参数
    函数的不定长参数
    打印星形三角
    九九乘法表
    udp客户端收发数据流程
  • 原文地址:https://www.cnblogs.com/chry/p/5876978.html
Copyright © 2011-2022 走看看