首页 > 数据库 >64怎样重置mysql(root)密码?

64怎样重置mysql(root)密码?

时间:2023-01-02 14:44:07浏览次数:54  
标签:tables skip server 64 mysql password root

  Mysql中可以使用root用户创建新用户或者修改用户的密码,但是如果当忘记root密码时,那么该怎样重置呢?这种主要分为三种不同类型的重置

  • Resetting the Root Password: Windows Systems
  • Resetting the Root Password: Unix and Unix-Like Systems
  • Resetting the Root Password: Generic Instructions

     第一种和第二种分别是针对window操作系统和unix操作系统,第三种主要是针对linux操作系统,这里就主要介绍第三种

Resetting the Root Password: Generic Instructions

  • Stop the MySQL server if necessary, then restart it with the --skip-grant-tables option. 
  • Connect to the MySQL server using the mysql client; no password is necessary because the server was started with --skip-grant-tables:   
  • In the mysql client, tell the server to reload the grant tables so that account-management statements work:
 mysql> FLUSH PRIVILEGES;

  Then change the 'root'@'localhost' account password. Replace the password with the password that you want to use. To change the password for a r  oot account with a different host name part, modify the instructions to use that host name.

 mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

You should now be able to connect to the MySQL server as root using the new password. Stop the server and restart it normally (without the --skip-grant-tables option and without enabling the skip_networking system variable).

这里说说补充一下flush privileges

flush privileges

  重新加载mysql 的授权表, If the --skip-grant-tables option was specified at server startup to disable the MySQL privilege system, FLUSH PRIVILEGES provides a way to enable the privilege system at runtime

  FLUSH PRIVILEGES resets failed-login tracking (or enables it if the server was started with --skip-grant-tables) and unlocks any temporarily locked accounts

  

标签:tables,skip,server,64,mysql,password,root
From: https://www.cnblogs.com/zmc60/p/17019891.html

相关文章

  • 最完美WIN10_Pro_22H2.19045.2364软件选装纯净版VIP38.3
    [系统简介】=============================================================1.本次更新母盘来WIN10_Pro_22H2.19045.2364。进一步优化调整。2.不支持更新,更新后精简版更新......
  • mysql的count(*),count(1),count(列)区别
    在开发过程中,时常会用到这个count函数,count表示进行统计操作,比如统计某张表的总数量。现实中,都是附带条件where进行统计。那么他们区别是什么呢?count()和count(1)统计的数据......
  • mysql数据库的分区与分表(概念性说明)
    为什么要分区或者分表分区、分表都是解决数据量大,查询数据慢的主要手段。正常情况下一个innodb表,在没有分区分表情况下。在数据库文件数据中,它是有一个存储表结构的.frm文件......
  • 使用root用户连接kali
    问题:直接通过命令sshroot@ip无法连接root用户解决方案:使用普通用户连接上之后在终端中(此处以windows的cmd窗口进行演示)进行root用户的切换直接通过root用户登录,......
  • Centos /etc/fstab/出错,提示 Give root password maintenance
    1、在登陆界面可以看见提示进入紧急模式2、输入root密码,进入系统,使用mount-a尝试挂载会提示有错误的挂载这种情况我碰见的是维修后磁盘的uuid发生变化,需要修改uuid3......
  • mysql-connector-java与mysql以及JDK的对应版本
    https://blog.csdn.net/xunxue1523/article/details/105524758?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ER......
  • Centos7安装Mysql8
    Centos7安装Mysql8一、环境预备1.1首先查看系统是否存在mysql,无则不返回rpm-qa|grepmysql1.2安装wgetyum-yinstallwget1.3抓取mariadb并删除包,无则不返回......
  • 部署mysql-5.7.36主从复制
    24.mysql实战24.1集群要求1.搭建一个主N从的MYsql集群2.从节点可以水平扩展3.所有的写操作,都只能在主节点Master上执行4.所有的读操作可以在所有节点上执行#部署......
  • Docker配置mysql主从复制
    ---先创建master实例dockerrun-p3307:3306--namemysql-master\-v/mydata/mysql-master/log:/var/log/mysql\-v/mydata/mysql-master/data:/var/lib/mysql\-v/myd......
  • mysql在linux下的安装 (附详细命令)
    安装环境:系统是ubuntn1、下载下载地址:http://dev.mysql.com/downloads/mysql/5.6.html#downloads下载版本:我这里选择的5.6.33,通用版,linux下64位也......