安装mysql链接服务出现ERROR 2003 (HY000) : Can't connect to MySQL server on '127.0.0.1:3306' (10061)

可能的原因是C:\ProgramData\MySQL\MySQL Server 8.0\Data目录没有清空

安装mysql无法链接数据库

ERROR 2003 (HY000) : Can't connect to MySQL server on '127.0.0.1:3306' (10061)

运行

mysqld --consle

2023-03-08T03:42:24.265727Z 0 [System] [MY-010116] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe (mysqld 8.0.32) starting as process 6940
2023-03-08T03:42:24.274418Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2023-03-08T03:42:24.274489Z 0 [Warning] [MY-010091] [Server] Can't create test file C:\Program Files\MySQL\MySQL Server 8.0\data\mysqld_tmp_file_case_insensitive_test.lower-test
2023-03-08T03:42:24.274898Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to 'C:\Program Files\MySQL\MySQL Server 8.0\data\' (OS errno: 2 - No such file or directory)
2023-03-08T03:42:24.275534Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-03-08T03:42:24.276680Z 0 [System] [MY-010910] [Server] C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe: Shutdown complete (mysqld 8.0.32)  MySQL Community Server - GPL.

发现文件无法在目录创建

解决方法

清空data目录

删除其他多余的文件

重新安装sql server