今天查看了一下mysql数据库,发现数据库密码忘记了。为此在这里总结一下,重置root密码的过程
数据库的目录结构
这里我使用的终端是git bash ,不是doc
在mysql/bin目录下打开git bash
./mysqld --defaults-file="E:\xx\db\my.ini" --console --skip-grant-tables
2021-04-22T05:51:47.056604Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-04-22T05:51:47.056604Z 0 [Warning] '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.
2021-04-22T05:51:47.056604Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2021-04-22T05:51:47.056604Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2021-04-22T05:51:47.056604Z 0 [Note] E:\xxx\db\bin\mysqld.exe (mysqld 5.7.20) starting as process 8964 ...
2021-04-22T05:51:47.066627Z 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2021-04-22T05:51:47.066627Z 0 [Note] InnoDB: Uses event mutexes
2021-04-22T05:51:47.066627Z 0 [Note] InnoDB: _mm_lfence() and _mm_sfence() are used for memory barrier
2021-04-22T05:51:47.066627Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2021-04-22T05:51:47.067683Z 0 [Note] InnoDB: Number of pools: 1
2021-04-22T05:51:47.068680Z 0 [Note] InnoDB: Not using CPU crc32 instructions
2021-04-22T05:51:47.071666Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2021-04-22T05:51:47.080648Z 0 [Note] InnoDB: Completed initialization of buffer pool
2021-04-22T05:51:47.105676Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2021-04-22T05:51:47.355617Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2021-04-22T05:51:47.355617Z 0 [Note] InnoDB: Setting file '.\ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2021-04-22T05:51:47.365710Z 0 [Note] InnoDB: File '.\ibtmp1' size is now 12 MB.
2021-04-22T05:51:47.373612Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2021-04-22T05:51:47.373612Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2021-04-22T05:51:47.374609Z 0 [Note] InnoDB: Waiting for purge to start
2021-04-22T05:51:47.425677Z 0 [Note] InnoDB: 5.7.20 started; log sequence number 260393122
2021-04-22T05:51:47.426692Z 0 [Note] InnoDB: Loading buffer pool(s) from E:\xxx\data\ib_buffer_pool
2021-04-22T05:51:47.426692Z 0 [Note] Plugin 'FEDERATED' is disabled.
2021-04-22T05:51:47.441673Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key
2021-04-22T05:51:47.441673Z 0 [Note] Server hostname (bind-address): '*'; port: 33036
2021-04-22T05:51:47.441673Z 0 [Note] IPv6 is available.
2021-04-22T05:51:47.442608Z 0 [Note] - '::' resolves to '::';
2021-04-22T05:51:47.442608Z 0 [Note] Server socket created on IP: '::'.
2021-04-22T05:51:47.490608Z 0 [Note] InnoDB: Buffer pool(s) load completed at 210422 13:51:47
2021-04-22T05:51:47.496649Z 0 [Note] E:\FFA\db\bin\mysqld.exe: ready for connections.
Version: '5.7.20' socket: '' port: 33036 MySQL Community Server (GPL)
2021-04-22T05:51:47.496649Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check.
2021-04-22T05:51:47.497668Z 0 [Note] Beginning of list of non-natively partitioned tables
2021-04-22T05:51:47.637673Z 0 [Note] End of list of non-natively partitioned tables
然后这个使用navicat连接
连接成功
- 这里出了一点小问题,不知道为啥用mysql -uroot 命令一直连不上系统(不知道为啥,求大佬解答)
然后在navicat中执行下面代码,root密码就重置成功
update mysql.user set authentication_string=password('123456') where user='root';
flush privileges;