1,管理员权限进入bin目录
D:\mysql-5.7.26-winx64\bin
2,初始化数据库
mysqld --initialize --console-08-22T02:41:07.449484Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). -08-22T02:41:07.732826Z 0 [Warning] InnoDB: New log files created, LSN=45790 -08-22T02:41:07.779341Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. -08-22T02:41:07.854672Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: ee6ec4f6-e420-11ea-8355-b42e9984629b. -08-22T02:41:07.857926Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. -08-22T02:41:07.866678Z 1 [Note] A temporary password is generated for root@localhost: w:CFD&o*p3jz 最后一行 w:CFD&o*p3jz 就是初始化密码
初始化后会多一个data文件夹,如果初始化密码忘记可以删除data重新初始化
D:\mysql-5.7.26-winx64\data
3,管理员权限进入bin目录安装服务
#安装服务 mysqld --install mysql #删除服务 mysqld --remove mysql #启动服务 net start mysql #停止服务 net stop mysql
4,安装好并启动服务,登录mysql
mysql -u root -p 密码输入上面的初始化密码 w:CFD&o*p3jz
5,修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456'; 如果是MySQL8.0.4以上版本 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';
6,忘记密码
密码都忘记了,还开发个锤子? 删库跑路吧!!!
如果觉得《Mysql安装教程 最简单的配置》对你有帮助,请点赞、收藏,并留下你的观点哦!