Modify the data storage location of the Mysql database (2)

Modify the data storage location of the Mysql database

Insert picture description here
After a year of hard work! Finally, my computer is full, and I added a T hard disk to expand the capacity,
but I need to modify the Mysql data storage location to E disk

Every day I turn on this computer to execute the crawler, there is a chill from my neck, for fear that it will explode directly

Since the Double Eleven has just ended recently, the database has been in frequent use, and I am not sure that the migration will be completed once, so I have not dared to move

The main steps are the same as the previous article: modify the data storage location of the Mysql database

The difference is that when the computer got Mysql installed for the first time, I modified it, but it didn’t work, and it couldn’t be used anymore. Fortunately, there was no data. I was able to do it in a few days, but mysql The datadir is still on the C drive. This is the reason why we are not sure of a successful migration. After all, four or five units have been changed, and the general ones are changed directly.

So for this data storage modification is really a lot of sweat

Fortunately, I did not eat this year, and after careful study, I found the following problems

There are two Mysql in the service, but Mysql is running, I began to wonder if the wrong object was configured before, so it did not take effect

But why there are two, I still don’t know
Insert picture description here

Carefully compared the attributes of the two services and found that Mysql does not --defaults-file

And Mysql80

 --defaults-file="C:\Program Files\MySQL\MySQL Server 8.0\my.ini"

It is the configuration file written before

Insert picture description here
Insert picture description here

Put my.ini into the installation folder corresponding to Mysql and
open the registry (administrator rights) under regedit

The path should be the same:

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet\Services\MySQL

Modify the ImagePath value of Mysql and add the path of the corresponding my.ini configuration file to:

"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe" --defaults-file="C:\Program Files\MySQL\MySQL Server 8.0\my.ini"MySQL

Insert picture description here

You net start mysqlcan start the service successfully here, even if you’re done,

The problem is that I can’t start it, restart it, or use mysql. It can connect to other computers, but it can’t connect to localhost.

Problem with mysql installation (The service already exists)

Refer to the above article and use the following commands

sc delete mysql  #删除该mysql
mysqld install  # 安装命令

net start mysql  # 启动mysql服务

Successfully resolved! !

Guess you like

Origin blog.csdn.net/qq_35866846/article/details/110039245