MySQL cannot log in after modifying the directory, Can't connect to MySQL server on localhost (10061)

Problem Description:

After installing and initializing mysql (after setting the environment variables), I modified the installation directory of mysql and closed mysql in the service. Then I started mysql again and found that I could not log in and start the service. as follows:Insert image description here

Solution process:

first step:

Since the directory has been changed, the environment variables need to be reconfigured.
Then run cmd in administrator mode, switch to the bin folder in the mysql installation directory, and use the mysqld --install command.

Step two:

After running, the path of the first installation appears. When it is determined that the environment variables have been modified correctly, it is inferred that the path in the registry has not been modified, and thus the path in the registry is modified.
Insert image description here

third step:

使用win+R命令,输入regedit打开注册表。找到mysql数据的存放位置
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
在目录中找到MYSQL文件夹,发现里面果然存有修改前的路径,随后修改为当前路径保存。

Insert image description here

the fourth step:

再次使用mysqld --install命令,发现目录已正常,接着使用net start mysql 会出现服务已启动窗口,此时能看到进程列表里面也有mysql进程在运行,启动成功。

Insert image description here

the fifth step:

Log in to mysql through the account and password. The login is successful and the problem is solved. Insert image description here
Post a reference link: https://blog.csdn.net/wolfking0608/article/details/82784297

Guess you like

Origin blog.csdn.net/qq_42914882/article/details/112845849