在mysql安装完成之后,使用命令 net start mysql 出现错误!
打开mysql/data/目录下的出错文件
2020-08-15T03:27:08.908407Z 0 [System] [MY-010116] [Server] D:Program Files (x86)mysql-8.0.16-winx64inmysqld.exe (mysqld 8.0.16) starting as process 14724
2020-08-15T03:27:08.930358Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
2020-08-15T03:27:08.930701Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2020-08-15T03:27:08.936536Z 0 [ERROR] [MY-010119] [Server] Aborting
2020-08-15T03:27:08.937821Z 0 [System] [MY-010910] [Server] D:Program Files (x86)mysql-8.0.16-winx64inmysqld.exe: Shutdown complete (mysqld 8.0.16) MySQL Community Server - GPL.
原因是data 文件夹初始化失败
重新初始化
mysqld --initialize --user=mysql --console
mysql-u root -p 登录时用初始化过程中生成的密码,然后修改数据库连接密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xxxxxx';