1:停止mysql服务
2:以管理员的身份打开cmd,然后输入mysqld --defaults-file=“C:\Program Files\MySQL\MySQL Server 5.6\my-default.ini” --console --skip-grant-tables
C:\windows\system32>mysqld --defaults-file=“C:\Program Files\MySQL\MySQL Server 5.6\my-default.ini” --console --skip-grant-tables
2018-09-28 13:54:23 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-09-28 13:54:23 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2018-09-28 13:54:23 0 [Note] mysqld (mysqld 5.6.40) starting as process 8476 …
2018-09-28 13:54:23 8476 [Note] Plugin ‘FEDERATED’ is disabled.
2018-09-28 13:54:23 8476 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-09-28 13:54:23 8476 [Note] InnoDB: The InnoDB memory heap is disabled
2018-09-28 13:54:23 8476 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2018-09-28 13:54:23 8476 [Note] InnoDB: Memory barrier is not used
2018-09-28 13:54:23 8476 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-09-28 13:54:23 8476 [Note] InnoDB: Not using CPU crc32 instructions
2018-09-28 13:54:23 8476 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-09-28 13:54:23 8476 [Note] InnoDB: Completed initialization of buffer pool
2018-09-28 13:54:23 8476 [Note] InnoDB: Highest supported file format is Barracuda.
2018-09-28 13:54:24 8476 [Note] InnoDB: 128 rollback segment(s) are active.
2018-09-28 13:54:24 8476 [Note] InnoDB: Waiting for purge to start
2018-09-28 13:54:24 8476 [Note] InnoDB: 5.6.40 started; log sequence number 55233480
2018-09-28 13:54:24 8476 [Note] Server hostname (bind-address): ‘*’; port: 3306
2018-09-28 13:54:24 8476 [Note] IPv6 is available.
2018-09-28 13:54:24 8476 [Note] - ‘::’ resolves to ‘::’;
2018-09-28 13:54:24 8476 [Note] Server socket created on IP: ‘::’.
2018-09-28 13:54:24 8476 [Note] mysqld: ready for connections.
Version: ‘5.6.40’ socket: ‘’ port: 3306 MySQL Community Server (GPL)
3:然后在重新以管理员的角色打开一个cmd,输入
use mysql;
update user set authentication_string=password(“root”) where user=“root” //string=password(“root”) root 是密码
flush privileges;