Solve phpstudy unable to start MySQL service

Recently, I am learning the content of the imitation site and need to use phpstudy. After downloading phpstudy, I want to start the MySQL service, but it always fails to start.
The main reason is that a MySQL service has been installed locally before, and the MySQL service in phpstudy and the local MySQL both occupy port 3306, resulting in a conflict.
However, it is very troublesome to modify the port number of any service, and you don't want to uninstall the MySQL service that was installed locally, so you can use the following methods to solve the service conflict:

  • First press win+R to execute services.msc to enter the service, find MySQL, click to stop the service, and then enter the local MySQL folder in the console cmd, my file name is mysql-8.0.26-winx64, execute the command after entering sc delete mysqlTo delete the service, it is found that the deletion cannot be performed because the operation must be performed as an administrator.
  • After the deletion is successful, the MySQL database on phpstudy will be automatically started.
    insert image description here
  • If you want to restart the local MySQL service, enter the mysql-8.0.26-winx64 folder as an administrator and execute the commandmysqld --install
  • Then win+R execute services.msc to enter the service and start the MySQL service
  • found that the service could not be started
    insert image description here

However, the MySQL in phpstudy can also be used after it is started. If you really want to use the local MySQL, you can use the following methods to solve the problem of not being able to start.

  • First delete the unstartable service as an administrator:sc delete mysql
  • Initialize the mysql service: mysqld --initialize, a data file will be generated in the mysql installation directory
    insert image description here
  • Install MySQL service:mysqld -install
  • Reinitialize once:mysqld --initialize-insecure
  • Then install the service again:mysqld -install
  • After entering the bin directory, start the service:net start mysql
  • Started successfully:
    insert image description here
    insert image description here

Although this method can successfully start the MySQL service, it essentially resets everything in the original MySQL, which means that the originally established database disappears and the original password cannot enter the database. It is necessary to modify the password of the MySQL database. can go in.

Since many versions for changing MySQL database passwords are outdated, I found a newer article to change the password. The blogger's MySQL database version is 8.0.19, while mine is 8.0.26. The method can successfully change the password.
insert image description here
insert image description here
Reference link: CSDN blog - ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) solution

Guess you like

Origin blog.csdn.net/m0_55887872/article/details/121956192