暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

mysql之用户密码

227decision 2020-06-02
868

mysql5


忘记密码,操作步骤:

  1. 修改mysql配置文件,在[mysqld]下面加上 skip-grant-tables (跳过权限的意思)。

  2. 重启mysql服务。

  3. mysql -uroot -p 无需密码登录进入。

  4. 修改密码,刷新权限后重新登录。


修改密码:3种方法

  • set password for 用户@ip = password('密码');

  • mysqladmin -u用户 -p旧密码 password 新密码;

  • update mysql.user set authentication_string=password('密码') where user='用户' and host='ip';


mysql8


忘记密码,操作步骤:

    第一步:cmd管理员身份运行,先停用mysql服务,net stop mysql服务名称
    C:\Windows\system32>net stop mysql80
    MySQL80 服务正在停止.
    MySQL80 服务已成功停止。
      第二步,执行命令:
      mysqld --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --console --skip-grant-tables --shared-memory


      C:\Windows\system32>mysqld --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --console --skip-grant-tables --shared-memory
      2020-06-02T12:48:38.678591Z 0 [Warning] [MY-010915] [Server] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
      2020-06-02T12:48:38.680414Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.19) starting as process 1304
      2020-06-02T12:48:39.444438Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
      2020-06-02T12:48:39.462853Z 0 [System] [MY-010931] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: ready for connections. Version: '8.0.19' socket: '' port: 0 MySQL Community Server - GPL.
      2020-06-02T12:48:39.638646Z 0 [Warning] [MY-011311] [Server] Plugin mysqlx reported: 'All I/O interfaces are disabled, X Protocol won't be accessible'
         第三步:另外开一个cmd,管理员身份运行,无密码登录
        C:\Windows\system32>mysql -uroot -p
        Enter password:
        Welcome to the MySQL monitor. Commands end with ; or \g.
        Your MySQL connection id is 7
        Server version: 8.0.19 MySQL Community Server - GPL


        Copyright (c) 2000, 2020, 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
          第四步:执行刷新权限命令:
          flush privileges;
            第五步:修改密码,执行命令
            ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
              第六步:再次执行刷新权限命令:
              flush privileges;
                第七步:当前cmd窗口,执行quit退出命令,保持当前cmd窗口,关闭上面打开的第一个cmd窗口。
                  第八步:启动mysql服务,用修改后的密码登录


                  C:\Windows\system32>net start mysql80
                  MySQL80 服务正在启动 .
                  MySQL80 服务已经启动成功。


                  C:\Windows\system32>mysql -uroot -p
                  Enter password: ********
                  Welcome to the MySQL monitor. Commands end with ; or \g.
                  Your MySQL connection id is 8
                  Server version: 8.0.19 MySQL Community Server - GPL


                  Copyright (c) 2000, 2020, 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后,依次执行“忘记密码的操作步骤”的第五步和第六步,然后quit,用修改后密码登录即可

                  最后修改时间:2020-07-01 12:54:26
                  文章转载自227decision,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

                  评论